Skip to content

Commit

Permalink
Cache the result of the iPhone 6+ check
Browse files Browse the repository at this point in the history
  • Loading branch information
c99koder committed Oct 15, 2014
1 parent 723c383 commit 5313341
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions IRCCloud/Classes/UIDevice+UIDevice_iPhone6Hax.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@

#import "UIDevice+UIDevice_iPhone6Hax.h"

BOOL __isBigPhone = NO;
BOOL __isBigPhone_set = NO;

@implementation UIDevice (UIDevice_iPhone6Hax)
-(BOOL)isBigPhone {
if(__isBigPhone_set)
return __isBigPhone;

if(![[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)])
return NO;
__isBigPhone = NO;
else
return [self userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] nativeScale] > 2.0f;
__isBigPhone = [self userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] nativeScale] > 2.0f;

__isBigPhone_set = YES;
return __isBigPhone;
}
@end

0 comments on commit 5313341

Please sign in to comment.