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的更多相关文章

  1. # ios开发 @property 和 Ivar 的区别

    ios开发 @property 和 Ivar 的区别 @property 属性其实是对成员变量的一种封装.我们先大概这样理解: @property = Ivar + setter + getter I ...

  2. (iOS)关于@property和@synthesize的理解(原创)

    开始学习ios的时候,就对一些objc的语法不理解,就比如@property和@synthesize,之前都是记住然后照着用,但是写的代码多了,对objc和ios有了一些理解,再加上最近用MRC,所以 ...

  3. IOS中@property的属性weak、nonatomic、strong、readonly等介绍

    iOS开发中@property的属性weak nonatomic strong readonly等介绍 //property:属性://synthesize:综合; @property与@synthe ...

  4. IOS Intro - Property Synthesis

    http://www.thecodecrate.com/ios/objective-c/objective-c-property-synthesize/ 01. atomic              ...

  5. iOS 中@property() 括号中,可以填写的属性?

    通过@property 和 @synthesize 属性可以简化设置器(set)和访问器(get) 的代码. 在@property 中又有那些属性呢? readwrite 默认 readonly 只读 ...

  6. ios的@property属性和@synthesize属性

    当你定义了一系列的变量时,需要写很多的getter和setter方法,而且它们的形式都是差不多的,,所以Xcode提供了@property 和@synthesize属性,@property用在 .h ...

  7. IOS 关于property的详细解法

    1.格式 @property (参数1,参数2,...) 类型 名字; eg: @property(nonatomic,retain) UIWindow *window; 其中参数主要分为三类: • ...

  8. ios的@property属性和@synthesize属性(转)

    当你定义了一系列的变量时,需要写很多的getter和setter方法,而且它们的形式都是差不多的,,所以Xcode提供了@property 和@synthesize属性,@property用在 .h ...

  9. ios变量的property属性设置和意义

    IOS 的@property和@synthesize帮我们轻易的生成对象的getter和setter方法来完成对对象的赋值和访问.但是如果我们如果要动态设置对象的getter和setter方法可以使用 ...

随机推荐

  1. 关于MyEclipse不停报错multiple problems have occurred 或者是内存不足 的解决办法

    这是因为 worksapace与svn代码不一样,要更新! 一更新就好了,困扰死我了,卧槽,搞了2个小时,难怪svn一提交就卡死人,原来还就是svn的问题,更新一下就行.

  2. cakephp 的query方法,直接写在controller中是否 有点不合适

    模型的query()函数有时是非常实用的,它可以在任何需要数据的地方执行SQL语句.但不是在什么地方调用query()方法都是恰当的.特别是在控制器中直接调用模型的query()方法 $this-&g ...

  3. RPC远程过程调用机制底层原理

  4. PAT (Advanced Level) 1070. Mooncake (25)

    简单贪心.先买性价比高的. #include<cstdio> #include<cstring> #include<cmath> #include<vecto ...

  5. 对于使用了SSH造成的中文乱码问题,4大解决方法

    修改struts2.xml struts2.xml 中添加 <constant name="struts.i18n.encoding" value="UTF-8&q ...

  6. mytop

    http://jeremy.zawodny.com/mysql/mytop/mytop.html 内容有点过时,用?查看帮助 vi set nuset nonu总记不住

  7. PAT (Advanced Level) 1014. Waiting in Line (30)

    简单模拟题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...

  8. ssh密钥登录及远程执行命令

    以192.168.1.104作为客户机 以192.168.1.103作为服务器 使用密钥登录 创建密钥对 在SSH客户机创建用户秘钥对 ssh-keygen -t rsa 之后全回车即可 将会在~/. ...

  9. linux undelete

    http://www.tldp.org/HOWTO/archived/Ext2fs-Undeletion-Dir-Struct/index.html http://www.giis.co.in/deb ...

  10. /etc/profile文件

    导读:Linux /etc/profile文件的改变会涉及到系统的环境,也就是有关Linux环境变量的东西,学习Linux要了解Linux profile文件的相关原理,这里对则以文件进行具体分析.这 ...