iOS 之 Property List
1. 概念
用于存储串行化对象,xml格式,存储到plist文件中。
2. 用途
存储用户设置。
3. 优点
- 程序运行时可动态创建和读写。
4. 使用说明
4.1. 获取plist文件
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *filePath = [documentPath stringByAppendingPathComponent:@"student.plist"];
4.2. 存储数据
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSDictionary *stu1= @{@"idNum":@"",@"name": @"jereh"};
[dict setValue:stu1 forKey:@"stu1"];
// 新数据写入plist文件
[dict writeToFile:filePath atomically:YES];
4.3. 读取数据
NSMutableDictionary *dicNow = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
int idNum = [[dicNow objectForKey:@"idNum"] intValue];
NSString *name = [dicNow objectForKey:@"name"];
iOS 之 Property List的更多相关文章
- # ios开发 @property 和 Ivar 的区别
ios开发 @property 和 Ivar 的区别 @property 属性其实是对成员变量的一种封装.我们先大概这样理解: @property = Ivar + setter + getter I ...
- (iOS)关于@property和@synthesize的理解(原创)
开始学习ios的时候,就对一些objc的语法不理解,就比如@property和@synthesize,之前都是记住然后照着用,但是写的代码多了,对objc和ios有了一些理解,再加上最近用MRC,所以 ...
- IOS中@property的属性weak、nonatomic、strong、readonly等介绍
iOS开发中@property的属性weak nonatomic strong readonly等介绍 //property:属性://synthesize:综合; @property与@synthe ...
- IOS Intro - Property Synthesis
http://www.thecodecrate.com/ios/objective-c/objective-c-property-synthesize/ 01. atomic ...
- iOS 中@property() 括号中,可以填写的属性?
通过@property 和 @synthesize 属性可以简化设置器(set)和访问器(get) 的代码. 在@property 中又有那些属性呢? readwrite 默认 readonly 只读 ...
- ios的@property属性和@synthesize属性
当你定义了一系列的变量时,需要写很多的getter和setter方法,而且它们的形式都是差不多的,,所以Xcode提供了@property 和@synthesize属性,@property用在 .h ...
- IOS 关于property的详细解法
1.格式 @property (参数1,参数2,...) 类型 名字; eg: @property(nonatomic,retain) UIWindow *window; 其中参数主要分为三类: • ...
- ios的@property属性和@synthesize属性(转)
当你定义了一系列的变量时,需要写很多的getter和setter方法,而且它们的形式都是差不多的,,所以Xcode提供了@property 和@synthesize属性,@property用在 .h ...
- ios变量的property属性设置和意义
IOS 的@property和@synthesize帮我们轻易的生成对象的getter和setter方法来完成对对象的赋值和访问.但是如果我们如果要动态设置对象的getter和setter方法可以使用 ...
随机推荐
- 关于MyEclipse不停报错multiple problems have occurred 或者是内存不足 的解决办法
这是因为 worksapace与svn代码不一样,要更新! 一更新就好了,困扰死我了,卧槽,搞了2个小时,难怪svn一提交就卡死人,原来还就是svn的问题,更新一下就行.
- cakephp 的query方法,直接写在controller中是否 有点不合适
模型的query()函数有时是非常实用的,它可以在任何需要数据的地方执行SQL语句.但不是在什么地方调用query()方法都是恰当的.特别是在控制器中直接调用模型的query()方法 $this-&g ...
- RPC远程过程调用机制底层原理
- PAT (Advanced Level) 1070. Mooncake (25)
简单贪心.先买性价比高的. #include<cstdio> #include<cstring> #include<cmath> #include<vecto ...
- 对于使用了SSH造成的中文乱码问题,4大解决方法
修改struts2.xml struts2.xml 中添加 <constant name="struts.i18n.encoding" value="UTF-8&q ...
- mytop
http://jeremy.zawodny.com/mysql/mytop/mytop.html 内容有点过时,用?查看帮助 vi set nuset nonu总记不住
- PAT (Advanced Level) 1014. Waiting in Line (30)
简单模拟题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
- ssh密钥登录及远程执行命令
以192.168.1.104作为客户机 以192.168.1.103作为服务器 使用密钥登录 创建密钥对 在SSH客户机创建用户秘钥对 ssh-keygen -t rsa 之后全回车即可 将会在~/. ...
- linux undelete
http://www.tldp.org/HOWTO/archived/Ext2fs-Undeletion-Dir-Struct/index.html http://www.giis.co.in/deb ...
- /etc/profile文件
导读:Linux /etc/profile文件的改变会涉及到系统的环境,也就是有关Linux环境变量的东西,学习Linux要了解Linux profile文件的相关原理,这里对则以文件进行具体分析.这 ...