iOS怎样在document目录下用代码创建一个文件
答案:2 悬赏:30
解决时间 2021-12-21 02:46
- 提问者网友:放荡不羁
- 2021-12-20 03:30
iOS怎样在document目录下用代码创建一个文件
最佳答案
- 二级知识专家网友:陪伴是最长情的告白
- 2021-12-20 05:07
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];
主要是获取路径,然后把文件写到这个路径里就好了
全部回答
- 1楼网友:爱情是怎么炼成的
- 2021-12-20 06:27
不一定需要。创建一个库一般处于一下两种目的: 1、把一些相关的代码,打包成一个库,发布给其它的人用。 这中情况是最常见的情况,如写 c 语言用到 libgcc。在这种情况下,你除了提供库文件:静态库[ windows 下 .lib,linux .a];
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯