The problem is that objectForKey:
of NSUserDefaults
returns a cocoa object - in this case, it is probably an NSNumber
. When you pass it to numberWithBool:
method, it treats nil
as NO
, and everything else as YES
.
If APICalls
is set as a boolean, you can use it directly, like this:
user.APICall = [defaults objectForKey:@"APICalls"];
If APICalls
is a number that you would like to re-interpret as a boolean, you can use this line instead:
user.APICall = [NSNumber numberWithBool:[[defaults objectForKey:@"APICalls"] intValue] != 0];