@fiy-fish
2015-08-14T09:28:38.000000Z
字数 867
阅读 1321
Objective-c
// main.m
// day09-04-plist文档
//
// Created by Aaron on 15/7/13.
// Copyright (c) 2015年 Aaron. All rights reserved.
//
#import <Foundation/Foundation.h>
//plist
//xml
#if 0
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSString *str = @"你麻痹dhjsagdkahsgkdg";
//字符串自己也提供了便捷的写入文件方法
[str writeToFile:@"/users/qianfeng/desktop/file10.txt" atomically:NO encoding:NSUTF8StringEncoding error:nil];
}
return 0;
}
#endif
//#if 0
int main()
{
NSString *name = @"蜡笔小新";
NSDictionary *dic = @{@"name":name};
[dic writeToFile:@"/users/qianfeng/desktop/plist1.plist" atomically:YES];
NSArray *array = @[name,dic];
[array writeToFile:@"/users/qianfeng/desktop/plist2.plist" atomically:YES];
//字典和数组的写入文件的方法,会将数据写入到plist文档里面
//plist根节点必须是数组或者字典
//plist可以存储的数据类型有:数组,字典,字符串,日期,二进制,数字,布尔值
NSDictionary *newDic = [NSDictionary dictionaryWithContentsOfFile:@"/users/qianfeng/desktop/plist1.plist"];
NSLog(@"%@",newDic);
}
//#endif