利用NSUserDefaults的可以快速的进行本地数据存储,但是支持的格式有限,
至于支持什么格式大家可以再自行脑补
我这边直接讲如何使用
NSUserDefaults 分为两部分
一个是存数据
![](https://yqfile.alicdn.com/img_1c53668bcee393edac0d7b3b3daff1ae.gif?x-oss-process=image/resize,w_1400/format,webp)
![](https://yqfile.alicdn.com/img_405b18b4b6584ae338e0f6ecaf736533.gif?x-oss-process=image/resize,w_1400/format,webp)
1 2 NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; 3 [defaults setObject:@"True" forKey:@"islogin"]; 4 [defaults synchronize]; 5
一个是取数据
![](https://yqfile.alicdn.com/img_1c53668bcee393edac0d7b3b3daff1ae.gif?x-oss-process=image/resize,w_1400/format,webp)
![](https://yqfile.alicdn.com/img_405b18b4b6584ae338e0f6ecaf736533.gif?x-oss-process=image/resize,w_1400/format,webp)
1 2 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults]; 3 NSString *haveimage=[defaults objectForKey:@"haveImage"];