What's the best way to get a value from NSUserDefaults on app load and store it in a global variable?

NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value NSUserDefaults Class Reference However, if you really want to have this 'constant' (it won't be a true constant though) do something like this pch: extern NSString *themeString AppDelegate. M: NSString *themeString = nil; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // ... themeString = NSUserDefaults standardUserDefaults objectForKey:@"Theme" copy; // ... }.

NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value. " - NSUserDefaults Class Reference However, if you really want to have this 'constant' (it won't be a true constant though) do something like this *. Pch: extern NSString *themeString; AppDelegate.

M: NSString *themeString = nil; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // ... themeString = NSUserDefaults standardUserDefaults objectForKey:@"Theme" copy; // ... }.

The problem is in my mainviewcontroller I declare user defaults and get its values. However since viewdidload is not called after user goes to settings and comes back to the app. My settings does not update.

But how will I pass the message to mainviewcontroller. Variables defined in app delegate are not recognised in mainviewcontroller.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions