Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cross platform Objective-C Strategy

1,351 views

Published on

  • Be the first to comment

  • Be the first to like this

Cross platform Objective-C Strategy

  1. 1. Patterns & Techniques For Cross-Platform Objective-C Code Graham Lee Smartphone Security Boffin, O2 @iamleeg
  2. 2. http://www.levenez.com/unix
  3. 3. http://www.levenez.com/unix
  4. 4. @interface O2LPerson : NSObject- (id)init;- (NSString *)name;- (NSArray *)phoneNumbers;// …@end
  5. 5. @interface O2LPerson : NSObject - (id)init; - (NSString *)name; - (NSArray *)phoneNumbers; // … @end@implementation O2LPerson {@privateO2LPersonStrategy *personStrategy;}- (NSString *)name {return [personStrategy name];}- (NSArray *)phoneNumbers {return [personStrategyphoneNumbers];}// …@end
  6. 6. @interface O2LPerson : NSObject - (id)init; - (NSString *)name; - (NSArray *)phoneNumbers; // … @end@implementation O2LPerson {@privateO2LPersonStrategy *personStrategy;}- (NSString *)name {return [personStrategy name];}- (NSArray *)phoneNumbers {return [personStrategyphoneNumbers];}// …@end@interface O2LPersonStrategyMac@interface O2LPersonStrategyiOS
  7. 7. @interface O2LPerson : NSObject - (id)init; - (NSString *)name; - (NSArray *)phoneNumbers; // … @end@implementation O2LPerson {@privateO2LPersonStrategy *personStrategy;}- (NSString *)name {return [personStrategy name];}- (NSArray *)phoneNumbers {return [personStrategyphoneNumbers];}// …@end@interface O2LPersonStrategyMac@interface O2LPersonStrategyiOS@interface O2LPersonStrategyLiveConnect
  8. 8. @interface O2LPerson : NSObject - (id)init; - (NSString *)name; - (NSArray *)phoneNumbers; // … @end@implementation O2LPerson- (id)init { [self release]; self = nil; if (iOS) return [[O2LPersoniOS alloc] init]; else if (mac) return [[O2LPersonMac alloc] init]; //…}- (NSString *)name {[self subclassResponsibility: _cmd];}// …@end
  9. 9. [frameworkObject hasShinyFeature][frameworkObject respondsToSelector:]
  10. 10. [frameworkObject hasShinyFeature][frameworkObject respondsToSelector:]NSClassFromString(@”ShinyClass”)
  11. 11. [frameworkObject hasShinyFeature][frameworkObject respondsToSelector:]NSClassFromString(@”ShinyClass”)[ShinyClass class] != nil
  12. 12. [frameworkObject hasShinyFeature][frameworkObject respondsToSelector:]NSClassFromString(@”ShinyClass”)[ShinyClass class] != nildlopen(”shiny.dylib”, RTLD_LAZY) != NULL
  13. 13. [frameworkObject hasShinyFeature][frameworkObject respondsToSelector:]NSClassFromString(@”ShinyClass”)[ShinyClass class] != nildlopen(”shiny.dylib”, RTLD_LAZY) != NULL#ifdef SHINYFEATURE
  14. 14.
  15. 15. …include $(GNUSTEP_MAKEFILES)/common.makePACKAGE_NAME = GFractalVERSION = 0.1# The application to be compiledAPP_NAME = GFractal# The Objective-C source files to be compiledGFractal_OBJC_FILES = main.m Controller.m FractalView.m FractalWindow.m # The Resource files to be copied into the apps resources directoryGFractal_RESOURCE_FILES = Icons/*include $(GNUSTEP_MAKEFILES)/application.make
  16. 16. “Be excellent to each other” Graham Lee Smartphone Security Boffin, O2 @iamleeg

×