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方法可以使用 ...
随机推荐
- Textbox服务器控件
<body> <form id="form1" runat="server"> <div> 姓名:<asp:TextB ...
- Android利用canvas画各种图形 及Paint用法 .
引自:http://blog.csdn.net/carlfan/article/details/8139984 1.首先说一下canvas类: Class Overview The Canvas cl ...
- C# 验证数字
/// <summary> /// 验证数字 /// </summary> /// <param name="number">数字内容</ ...
- web开发后端开源库收集
1.Gregwar/Captcha 项目地址:https://github.com/Gregwar/Captcha
- c# 错误 两个输出文件名解析为同一个输出路径
检查同项目的其他文件夹下面已有其他同名窗体,影响设计器
- HDU 5166 Missing number 简单数论
Missing number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) [ ...
- gridcontrol第一行为0,没有选中为-999999
- iOS下bound,center和frame
本文转发至:http://www.xuebuyuan.com/1846606.html 在写程序的时候发现,iOS下的坐标.位置很容易弄乱,特别是在不同的坐标系统中,必须完成弄明白一些概念才能做相应的 ...
- mrql初级教程-概念、使用(一)
以下是本人原创,如若转载和使用请注明转载地址.本博客信息切勿用于商业,可以个人使用,若喜欢我的博客,请关注我,谢谢!博客地址 感谢您支持我的博客,我的动力是您的支持和关注!如若转载和使用请注明转载地址 ...
- 为什么jQuery要返回jQuery.fn.init对象
作者:zccst jQuery = function( selector, context ) { // The jQuery object is actually just the init con ...