iOS学习(三十一)IOS中获取home文件的目录,分别保存字符串,数组,字典
2016-07-12 21:42
423 查看
IOS中获取home文件的目录,分别保存字符串,数组,字典
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //保存字符串 NSString *path = NSHomeDirectory(); /*path = [path stringByAppendingPathComponent:@"abcd.txt"]; NSLog(@"%@",path); NSString * str = @"1234"; [str writeToFile:path atomically:YES];*/ //保存数组使用plist,可以使用xcode打开,当然可以用txt保存 /*path = [path stringByAppendingPathComponent:@"efg.plist"]; NSLog(@"%@",path); NSArray * arr =[NSArray arrayWithObjects:@"1111",@"2222",@"3333",@"4444",@"5555", nil]; [arr writeToFile:path atomically:YES];*/ //字典保存文件 path = [path stringByAppendingPathComponent:@"dict.plist"]; NSLog(@"%@",path); NSDictionary *dic =[NSDictionary dictionaryWithObjectsAndKeys:@"zhangsan", @"name",@"21",@"age",@"男",@"sex",nil]; [dic writeToFile:path atomically:YES]; }
相关文章推荐
- Android之使用Http协议实现文件上传功能
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 菜鸟说给菜鸟听之Beginning Linux Programming——Chapter1(1)
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- sqlserver FOR XML PATH 语句的应用
- set_include_path在win和linux下的区别
- 浅析Cookie中的Path与domain
- cookie中的path与domain属性详解
- PHP include_path设置技巧分享
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用开发中AFNetworking库的常用HTTP操作方法小结
- iOS应用中UISearchDisplayController搜索效果的用法
- iOS App开发中的UISegmentedControl分段组件用法总结