由于某些原因,当我的应用运行沙盒时,我无法将文件保存到我的应用文档文件夹。
这是我的方法:
-(void) saveShotToDevice:(UIImage *)shot {
// Get the documents directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imageFile = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"Sequence%iShot%i.jpg",
currentSequenceId,
currentSequenceShot]
];
currentSequenceShot++;
NSData *imageData = UIImageJPEGRepresentation(shot, 1.0);
[imageData writeToFile:imageFile atomically:YES];
[sequencesDB saveShot:currentSequenceId:imageFile];
}
这是控制台日志
Nov 9 17:13:09 unknown sandboxd[176] <Notice>: Nabit(175) deny file-write-create /dh?ph?#,
Nov 9 17:13:10 unknown Nabit[175] <Warning>: Image path: /var/mobile/Applications/3F9A2648-B104-4D35-AD06-30A8F338096B/Documents/Sequence0Shot0.jpg
由于某些原因,图像路径似乎在沙盒模式下被错误地格式化了,但我真的无法弄清楚原因。
答案 0 :(得分:0)
我找到了解决方案。
这不是我概述的方法,而是我的[sequencesDB saveShot:currentSequenceId:imageFile];
方法。
数据库从未在沙盒模式下成功创建。