NSUserDefaults. setValue works, Not setBool

前端 未结 4 1673
春和景丽
春和景丽 2021-01-18 02:16

I trying to store some settings in NSUserDefaults, but It seems that the app won\'t store the setBool values.

This works:

[[NSUserDefaults standardUs

4条回答
  •  孤街浪徒
    2021-01-18 02:43

    XCode 4.6 seems to have the same problem highlighted by hangzhouharry. A useful call is [[NSUserDefaults standardUserDefaults] dictionaryRepresentation] to see if your key values are looking the way they should.

    For example -> autoLogout = 0;

    which was set as a Bool, [settings boolForKey:@"autoLogout"] returns nothing

    [settings integerForKey:@"autoLogout"] returns 0 (as, sort of, expected)

提交回复
热议问题