您的位置:首页 > 其它

在沙盒中创建文件方法

2015-08-10 22:23 211 查看
- (void)creatPlistFile{
NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *path = [array objectAtIndex:0];
// 拼接phoneContact.plist时,有的Xcode不加/也行

plistPath = [path stringByAppendingString:@"/phoneContact.plist"];

NSFileManager *fileManager = [[NSFileManager alloc]init];
if (![fileManager fileExistsAtPath:plistPath]) {
BOOL isOk = [fileManager createFileAtPath:plistPath contents:nil attributes:nil];
if (isOk) {
NSLog(@"创建成功");
}
else{
NSLog(@"创建失败");
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: