ios-沙盒机制,简单写入文件
viewController.m
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//在沙盒中创建文件夹
//1.创建fileManager对象
NSFileManager *fileManager = [NSFileManager defaultManager];
//2.沙盒路径
NSString *tempPath = NSTemporaryDirectory();
//3.创建相应的文件夹
NSString *filePath = [tempPath stringByAppendingPathComponent:@"path1/path2"];
//4.在相应的位置把文件夹放入沙盒
[fileManager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
NSLog(@"%@",filePath);
NSString *filePath2 = [tempPath stringByAppendingString:@"pat