Skip to content

Commit 4762a9d

Browse files
author
jrapoport
committed
Be kind to < iOS7
Don’t break anyone targeting iOS 6 or before
1 parent 9596208 commit 4762a9d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

AWLThemeManager/AWLThemeManager.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,21 @@ - (UIImage *)imageNamed:(NSString *)key forTheme:(NSString*)themeName
141141
if (NSFoundationVersionNumber >= NSFoundationVersionNumber_iOS_8_0) {
142142
img = [UIImage imageNamed:key inBundle:bundle compatibleWithTraitCollection:nil];
143143
}
144-
else {
145144
#ifdef AWLThemeManager_XCASSETS_iOS7
145+
else {
146146
//This is included for reference/completeness. It fetches the device specific
147147
//image from the compiled Assets.car embedded in the theme bundle for iOS7 devices.
148148
//However, it is a *PRIVATE API*
149149
//As such, all relevant warnings and caveats apply to it's usage
150150
//IF you want to enable with cocoapods you'll need this:
151151
//https://guides.cocoapods.org/syntax/podfile.html#post_install
152152
static NSString* iOS7PrivateCompatSelector = @"_" @"device" @"Specific" @"ImageNamed:" @"inBundle:";
153-
img = [UIImage performSelector:NSSelectorFromString(iOS7PrivateCompatSelector) withObject:imgName withObject:bundle];
154-
#endif
153+
SEL deviceImageNamed = NSSelectorFromString(iOS7PrivateCompatSelector);
154+
if ([UIImage respondsToSelector: deviceImageNamed]) {
155+
img = [UIImage performSelector: deviceImageNamed withObject:imgName withObject:bundle];
156+
}
155157
}
158+
#endif
156159

157160
if (img == nil) {
158161
NSString *path = self.themeList[themeName];

0 commit comments

Comments
 (0)