Iphone writeToPath:原子性:-不确定为什么会失败

Iphone writeToPath:原子性:-不确定为什么会失败,iphone,objective-c,nsdictionary,nsdata,Iphone,Objective C,Nsdictionary,Nsdata,这是我的密码。NSDictionary曾经是一个东西,但我在试图找到问题时暂时删除了它 NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Entries/"]; NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL isDirectory = NO; BOOL directoryExis

这是我的密码。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

问题可能是
字典
包含的项不是属性列表对象,如所述:

此方法在写入文件之前递归验证所有包含的对象是否都是属性列表对象(NSData、NSDate、NSNumber、NSString、NSArray或NSDictionary的实例),如果所有对象都不是属性列表对象,则返回“否”,因为生成的文件不是有效的属性列表


您是否检查过sim卡的文档目录以查看该文件是否存在?
[JMedia generate uuistring]
方法返回一个完全随机的字符串,因此它不可能已经存在。目前
字典
为零,所以这是行不通的。你能在删除
字典
的值之前发布原始代码吗?我想到了这一点,这就是为什么我让NSDictionary不包含任何对象的原因。所以我知道这不是问题所在。在当前代码中,
NSDictionary
不是不包含任何对象的字典,它是
nil
。这就是为什么您现在获得了
成功:0