[关闭]
@fiy-fish 2015-08-14T09:28:38.000000Z 字数 867 阅读 1321

day09-04-plist文档

Objective-c


  1. // main.m
  2. // day09-04-plist文档
  3. //
  4. // Created by Aaron on 15/7/13.
  5. // Copyright (c) 2015年 Aaron. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. //plist
  9. //xml
  10. #if 0
  11. int main(int argc, const char * argv[]) {
  12. @autoreleasepool {
  13. NSString *str = @"你麻痹dhjsagdkahsgkdg";
  14. //字符串自己也提供了便捷的写入文件方法
  15. [str writeToFile:@"/users/qianfeng/desktop/file10.txt" atomically:NO encoding:NSUTF8StringEncoding error:nil];
  16. }
  17. return 0;
  18. }
  19. #endif
  20. //#if 0
  21. int main()
  22. {
  23. NSString *name = @"蜡笔小新";
  24. NSDictionary *dic = @{@"name":name};
  25. [dic writeToFile:@"/users/qianfeng/desktop/plist1.plist" atomically:YES];
  26. NSArray *array = @[name,dic];
  27. [array writeToFile:@"/users/qianfeng/desktop/plist2.plist" atomically:YES];
  28. //字典和数组的写入文件的方法,会将数据写入到plist文档里面
  29. //plist根节点必须是数组或者字典
  30. //plist可以存储的数据类型有:数组,字典,字符串,日期,二进制,数字,布尔值
  31. NSDictionary *newDic = [NSDictionary dictionaryWithContentsOfFile:@"/users/qianfeng/desktop/plist1.plist"];
  32. NSLog(@"%@",newDic);
  33. }
  34. //#endif
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注