Created
December 8, 2010 20:43
-
-
Save shawn42/733887 to your computer and use it in GitHub Desktop.
Example
This file contains hidden or 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
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
ObjectionInjector *injector = [Objection createInjector]; | |
[Objection setGlobalInjector:injector]; | |
} | |
- (void)viewDidLoad { | |
id myModel = [[Objection globalInjector] getObject:[MyModel class]]; | |
} |
This file contains hidden or 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
@class Engine, Brakes; | |
@interface Car : NSObject | |
{ | |
Engine *engine; | |
Brakes *brakes; | |
BOOL awake; | |
} | |
// Will be filled in by objection | |
@property(nonatomic, retain) Engine *engine; | |
// Will be filled in by objection | |
@property(nonatomic, retain) Brakes *brakes; | |
@property(nonatomic) BOOL awake; | |
@implementation Car | |
objection_register(Car) | |
objection_requires(@"engine", @"brakes") | |
@synthesize engine, brakes, awake; | |
@end |
This file contains hidden or 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
- (void)someMethod { | |
ObjectionInjector *injector = [Objection createInjector]; | |
id car = [injector getObject:[Car class]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment