Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Chapter 12: default for standardUserDefaults vs "Default" in plist settings file

1. In AppDelegate, we register default for standardUserDefaults:


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    NSDictionary *defaults = @{

                               kWarpDriveKey : @YES,

                               kWarpFactorKey : @5,

                               kFavoriteSinKey : @"Greed"};

    

    [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];

    return YES;

}


2. We also have Default values for some items in plist file, for example, DefultValue for item5 in More.plist is "Greed". If we change it, for example, for "Lust", we will see that firs screen of app will still show "Greed" as a Favorite sin, but in Settings App we see "Lust" shows as Favorite sin.


So, in our app we are not actually show the settings that we can see in Settings App but rather those values from standardUserDefaults default (that, as we can see, does not reflect what is actually shown in Settings). 


it's confusing. Is there any way to "synchronize" those two type of defaults? I mean, can we somehow say "take it from "Default" value from plist if there is one" when defining default for standardUserDefaults?

Sign In or Register to comment.