I have a singleton Session
that I want instantiated at application launch. How do I do that?
I'm using this method of creating the singleton: http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html
In the first line of your didFinishLaunchingWithOptions
method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[YourSingletonClass class]; // ADD THIS LINE
it will trigger initialize
method initialization in your singleton class
+ (void) initialize {
_innerInstance = [[YourSingletonClass alloc] init];
}
If you access the singleton in the applicationDidFinishLaunching:
method, they will should get set up.
精彩评论