IPhone SDK Default NSUserDefaults

后端 未结 3 1537
你的背包
你的背包 2021-01-15 10:32

I have set up the user defaults to record a integer for a UISlider, the problem is that, if the user has only just installed the app then the integer is zero or NULL. Is the

3条回答
  •  终归单人心
    2021-01-15 11:21

    You should set a valid default value for each of your preferences. This value will be used when one has not been set by the user.

    NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
    [defaults setObject:[NSNumber numberWithInt:25] forKey:@"senset"];
    [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
    

提交回复
热议问题