Skip to content

Commit dac8ea4

Browse files
committed
Fix issue CEWendel#297: Availability checks for Objective-C
1 parent d036d47 commit dac8ea4

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

MGSwipeTableCell/MGSwipeButton.m

+6-8
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,16 @@ - (BOOL)isAppExtension
161161
return [[NSBundle mainBundle].executablePath rangeOfString:@".appex/"].location != NSNotFound;
162162
}
163163

164-
165164
-(BOOL) isRTLLocale
166165
{
167-
if ([[UIView class] respondsToSelector:@selector(userInterfaceLayoutDirectionForSemanticContentAttribute:)]) {
166+
if (@available(iOS 9, *)) {
168167
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft;
168+
}
169+
else if ([self isAppExtension]) {
170+
return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
169171
} else {
170-
if ([self isAppExtension]) {
171-
return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
172-
} else {
173-
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
174-
return application.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
175-
}
172+
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
173+
return application.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
176174
}
177175
}
178176

MGSwipeTableCell/MGSwipeTableCell.m

+6-7
Original file line numberDiff line numberDiff line change
@@ -658,15 +658,14 @@ - (BOOL)isAppExtension
658658

659659
-(BOOL) isRTLLocale
660660
{
661-
if ([[UIView class] respondsToSelector:@selector(userInterfaceLayoutDirectionForSemanticContentAttribute:)]) {
661+
if (@available(iOS 9, *)) {
662662
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft;
663+
}
664+
else if ([self isAppExtension]) {
665+
return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
663666
} else {
664-
if ([self isAppExtension]) {
665-
return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
666-
} else {
667-
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
668-
return application.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
669-
}
667+
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
668+
return application.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
670669
}
671670
}
672671

0 commit comments

Comments
 (0)