Setting bundle default value won't set

前端 未结 5 967
小蘑菇
小蘑菇 2021-01-04 02:29

I have an iOS application with a settings.bundle that handles various settings for my application with Switch toggle. I set default values in my root.plist file

5条回答
  •  伪装坚强ぢ
    2021-01-04 03:11

    The Default Value is used by Settings.app for display purposes only. If you don't change the value in the settings app nothing is saved to NSUserDefaults.

    You have to register the default values yourself. Use something like this in application:didFinishLaunchingWithOptions::

    NSDictionary *userDefaultsDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
                                          [NSNumber numberWithBool:YES], @"localetime",
                                          nil];
    [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsDefaults];
    

提交回复
热议问题