iOS 本地存储数据的几种方式


iOS 本地存储数据的几种方式

https://www.jianshu.com/p/dd0b55d80736

NSUserDefaults 方式存储

  • 写入
1
2
3
NSUserDefaults *login = [NSUserDefaults standardUserDefaults];
[login setObject:self.passwordField.text forKey:@"token"];
[login synchronize];
  • 读取
1
2
NSUserDefaults *login = [NSUserDefaults standardUserDefaults];
NSString *str = [login objectForKey:@"token"];