0

我有这个:

NSMutableDictionary *responseDict = [responseString objectFromJSONString];

        NSLog(@"%@" , [responseDict objectForKey:@"loginid"]);

我想把我的“登录名”放到 NSUserDefault..

如何将 loginid 值放入 NSUserDefault 和 Retrieve ?

我试过这种方式但不能正常工作

[默认 setInteger:[responseDict objectForKey:@"loginid"] forKey:@"user_id"];

请需要帮助

提前致谢

4

1 回答 1

0

要放入NSUserDefaults你可以这样做

为了节省:

NSString *logInId = [NSString stringWithFormat:@"%@",[responseDict objectForKey:@"loginid"]];
NSUserDefaults *preferences = [NSUserDefaults standardDefaults];
[preferences setValue:logInId forKey:@"logInId"];
[preferences synchronize];

对于检索:

NSUserDefaults *preferences = [NSUserDefaults standardDefaults];
NSString *logInIdValue = [preferences valueForKey:@"logInId"];
于 2013-05-16T05:17:07.703 回答