ios 开发使用代码创建文件智能放在沙盒吗,除了沙盒能放在工程目录下吗
1个回答
展开全部
NSString *home = NSHomeDirectory();//获取沙盒路径
//拼接Documents路径
//NSString *docPath = [home stringByAppendingStringt:@"/Documents"];
NSString *docPath = [home stringByAppendingPathComponent:@"Documents"];
NSString *filePath = [docPath stringByAppendingPathComponent:@"data.plist"];
NSArray *array = @[@1,@2,@"123"];
//只有具备writeToFile的对象才能使用plist存储,NSArray
[array writeToFile:filePath atomically:YES];
主要是获取路径,然后把文件写到这个路径里就好了
//拼接Documents路径
//NSString *docPath = [home stringByAppendingStringt:@"/Documents"];
NSString *docPath = [home stringByAppendingPathComponent:@"Documents"];
NSString *filePath = [docPath stringByAppendingPathComponent:@"data.plist"];
NSArray *array = @[@1,@2,@"123"];
//只有具备writeToFile的对象才能使用plist存储,NSArray
[array writeToFile:filePath atomically:YES];
主要是获取路径,然后把文件写到这个路径里就好了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询