存
int userid = userId; [userDefault setInteger:userid forKey:@"userId"];
取
long userId = [[NSUserDefaults standardUserDefaults] integerForKey:@"userId"];
存的时候userId是id类型。 这时候我取出的数是一个很大的数。请问这是怎么回事?
走同样的路,发现不同的人生
Use setObject to save the id variable when saving, and use integerForKey when fetching.
The problem is
int userid = userId;
should be changed to
NSInteger userid = userId; ...
Because NSInteger != int
See picture
Use setObject to save the id variable when saving, and use integerForKey when fetching.
The problem is
should be changed to
Because
NSInteger != int
See picture