存
int userid = userId;
[userDefault setInteger:userid forKey:@"userId"];
取
long userId = [[NSUserDefaults standardUserDefaults] integerForKey:@"userId"];
存的时候userId是id类型。
这时候我取出的数是一个很大的数。请问这是怎么回事?
天蓬老师2017-04-17 15:46:07
Use setObject to save the id variable when saving, and use integerForKey when fetching.
怪我咯2017-04-17 15:46:07
The problem is
int userid = userId;
should be changed to
NSInteger userid = userId;
...
Because
NSInteger != int
See picture