這是我有的代碼。 NSDictionary確實曾經是一些東西,但是我試圖找到問題時暫時刪除了它。writeToPath:原子地: - 不知道爲什麼這是失敗
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Entries/"];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDirectory = NO;
BOOL directoryExists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
if (!directoryExists) {
[fileManager createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:nil];
}
if ([self.pathName isEqualToString:@""] || self.pathName == nil) {
self.pathName = [NSString stringWithFormat:@"%@.JEntry", [JMedia generateUuidString]];
}
NSString *entryPath = [path stringByAppendingPathComponent:self.pathName];
NSDictionary *dictionary;
NSLog(@"entrypath: %@", entryPath);
BOOL success = [dictionary writeToFile:entryPath atomically:YES];
NSLog(@"success: %i", success);
的NSLog:
entrypath: /var/mobile/Applications/1B838285-8326-427A-8AC5-0D5567C3CD81/Documents/Entries/70AFCF6D-540E-436E-9989-68793500E35B.JEntry
success: 0
你檢查了SIM的文檔目錄,看看文件是否存在? – CodaFi 2012-03-24 18:23:48
'[JMedia生成UuidString]'方法會帶回一個完全隨機的字符串,因此它不可能已經存在。 – Andrew 2012-03-24 18:28:50
目前'字典'是零,所以這是永遠不會工作。 – jrturton 2012-03-24 18:31:10