【发布时间】:2012-03-24 18:13:38
【问题描述】:
这是我的代码。 NSDictionary 确实曾经是一些东西,但我在试图找到问题时暂时删除了它。
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的文档目录看文件是否存在?
-
[JMedia generate UuidString]方法返回一个完全随机的字符串,因此它不可能已经存在。 -
目前
dictionary为零,所以这永远行不通。 -
在去掉
dictionary的值之前能不能贴一下原代码?
标签: iphone objective-c nsdictionary nsdata