iOS中plist的快速生成方法
来源:互联网 发布:卡苏马苏奶酪 知乎 编辑:程序博客网 时间:2024/05/24 02:21
在之前的工作当中,曾经需要配置一个Plist文件,当时傻傻的一条一条输入,耗费了很长的时间.后来公司大神教了一个很好地方法,现在特此记录一下
NSArray *name = [[NSArray alloc]initWithObjects:@"Achafexp",@"Bonkers",@"carolingia",@"catholicschoolgirls",@"Chubsy",@"devroye",@"donreesclaws",@"feenacasual",@"Flakes",@"Gangster",@"gothic_ultra_ot",@"Howardson",@"Husser",@"JustOldFashion",@"Kells_SD",@"Kensinton",@"Kookazoo",@"littlelordfontleroy",@"Mothproof_Script",@"Nuttipy",@"OldSchool",@"oliver",@"Percirk",@"readyformycloseup",@"Reginald",@"SFCollegiateSolid",@"Tangerine_Bold",@"Zainly", nil]; NSLog(@"%d",name.count); NSMutableArray *all = [[NSMutableArray alloc]initWithCapacity:0]; for (int i = 0; i<28; i++) { NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:[name objectAtIndex:i],@"font",@"hello",@"text", nil]; [all addObject:dict]; } NSString *tempPath = NSTemporaryDirectory();NSString *path = [tempPath stringByAppendingPathComponent:@"EnFontPList.plist"];[all writeToFile:path atomically:YES];
//其核心,主要就是NSString *path = [tempPath stringByAppendingPathComponent:@"EnFontPList.plist"];[all writeToFile:path atomically:YES];
atomically参数解释
这个参数意思是如果为YES则保证文件的写入原子性,就是说会先创建一个临时文件,直到文件内容写入成功再导入到目标文件里.
如果为NO,则直接写入目标文件里.
这样就可以生成一个plist啦,很方便是不是,哈哈~
源码:Plist 动态写入DEMO
0 0
- iOS中plist的快速生成方法
- iOS-生成plist文件,在项目中代码创建plist
- ios中读取plist文件内容的方法
- iOS中使用.plist文件延迟读取的方法
- iOS plist的存取快速入门
- iOS中plist的操作
- iOS中plist的详解
- IOS获取plist文件属性值的方法
- IOS获取plist文件属性值的方法
- iOS获取plist文件属性值的方法
- IOS Info.plist中常用的key
- iOS中plist的读写操作
- IOS中plist文件内容的读取
- iOS中使用.plist文件延迟读取的方法(续)
- iOS开发:一个快速生成model属性的方法
- iOS 的info.plist
- 【iOS】plist的使用
- iOS plist的创建
- 前端程序员必上的8个优秀的中文前端设计网站
- 接口抽象类hashtable集合整理文档
- js与jquery获得页面大小、滚动条位置、元素位置
- 启联web服务器V1.0,正式发布
- javascript获取网页URL地址及参数等
- iOS中plist的快速生成方法
- javascript cookies 存、取、删除实例
- Unity手游之路<四>3d旋转-四元数,欧拉角和变幻矩阵
- MFC Loads Wrong Resource in Extension DLL
- stream_set_blocking让程序无阻塞
- stream_set_timeout的使用方法
- Heroku:快速部署Dropwizard开发的RESTful Service
- last time ? first time : continue
- 如何在Linux上制作一个屏幕录像视频教程