在沙盒中创建文件方法1

 

 

 

 

 

 

 1 - (void)creatPlistFile{
 2     NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
 3     NSString *path = [array objectAtIndex:0];
// 拼接
phoneContact.plist时,有的Xcode不加/也行
 4 plistPath = [path stringByAppendingString:@"/phoneContact.plist"];
5 NSFileManager *fileManager = [[NSFileManager alloc]init]; 6 if (![fileManager fileExistsAtPath:plistPath]) { 7 BOOL isOk = [fileManager createFileAtPath:plistPath contents:nil attributes:nil]; 8 if (isOk) { 9 NSLog(@"创建成功"); 10 } 11 else{ 12 NSLog(@"创建失败"); 13 } 14 } 15 }

 

posted @ 2015-08-10 22:23  凝月霜雪  阅读(175)  评论(0)    收藏  举报