码迷,mamicode.com
首页 > 移动开发 > 详细

iOS plist

时间:2016-05-27 14:29:48      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

//存

NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);

    NSString *path=[paths objectAtIndex:0];

    NSLog(@"path = %@",path);

    NSString *filename=[path stringByAppendingPathComponent:@"test.plist"];

    NSFileManager* fm = [NSFileManager defaultManager];

    [fm createFileAtPath:filename contents:nil attributes:nil];

    //创建一个dic,写到plist文件里

    NSDictionary* dic = @{@"image":str};

    NSLog(@"dic----%@",dic);

    [dic writeToFile:filename atomically:YES];

 

//取

NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);

    NSString *path=[paths objectAtIndex:0];

    NSString *filename=[path stringByAppendingPathComponent:@"test.plist"];

    NSDictionary* dic2 = [NSDictionary dictionaryWithContentsOfFile:filename];

    NSLog(@"dic2---%@",dic2);

iOS plist

标签:

原文地址:http://www.cnblogs.com/tongyuling/p/5534278.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!