Last active
March 13, 2017 09:18
-
-
Save Phillipus/6279347 to your computer and use it in GitHub Desktop.
Class Cluster example as described here - http://www.noxeos.com/2013/06/18/strategies-support-ios7-ui/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface MyView : UIView | |
- (void)kissMyAss; | |
@end | |
@interface _MyViewIOS6 : MyView | |
@end | |
@interface _MyViewIOS7 : MyView | |
@end | |
@implementation MyView | |
BOOL isIOS7 = YES; // This would be a function somewhere | |
+ (id)alloc { | |
if([self class] == [MyView class]) { | |
if(isIOS7) { | |
return [_MyViewIOS7 alloc]; | |
} | |
else { | |
return [_MyViewIOS6 alloc]; | |
} | |
} | |
return [super alloc]; | |
} | |
- (void)kissMyAss {} | |
// Test method | |
+ (void)testClassCluster { | |
MyView *myView = [[MyView alloc] init]; | |
[myView kissMyAss]; | |
} | |
@end | |
@implementation _MyViewIOS6 | |
- (void)kissMyAss { | |
NSLog(@"iOS 6 can kiss my ass"); | |
} | |
@end | |
@implementation _MyViewIOS7 | |
- (void)kissMyAss { | |
NSLog(@"iOS 7 can kiss my ass"); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment