Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将附加项写入磁盘失败_Iphone_Ios_Objective C_Ipad - Fatal编程技术网

Iphone 将附加项写入磁盘失败

Iphone 将附加项写入磁盘失败,iphone,ios,objective-c,ipad,Iphone,Ios,Objective C,Ipad,我有以下代码: NSData * JSONData = [MyJSON dataWithJSONObject:highlightItemsArray]; if ([JSONData isNotNull]){ NSError *error; BOOL writeToDiskSuccess = [JSONData writeToFile:self.highlightDiskCachePa

我有以下代码:

 NSData * JSONData = [MyJSON dataWithJSONObject:highlightItemsArray];
                if ([JSONData isNotNull]){
                    NSError *error;
                    BOOL writeToDiskSuccess = [JSONData writeToFile:self.highlightDiskCachePath_ options:NSDataWritingAtomic error:&error];
                    if (!writeToDiskSuccess){
                        NSLog(@"Writing appended caption failed %@", error);
                    } else {
                        NSLog(@"Writing appended caption succeed");
                    }
                }

但是,当printed为null时,此处返回NO和error。我怎样才能找出问题所在?

我认为您需要添加更多详细信息才能在这里得到答案

我假设你得到writeToDiskSuccess=FALSE?如果是这样的话,我要看的第一件事是,如果你写错了目录。。。能否给出self.highlightDiskCachePath的值?你在模拟器上也有同样的错误吗?如果是这样的话,您应该能够在Finder中导航到那里,看看是否有丢失的path元素或其他一些磁盘问题,以及为什么它不能在那里写入

最后,我要检查它是否不是特定于JSONData writeToFile失败的东西。。。你能把一个简单的文本文件写到你要写的地方吗


同样值得注意的是,控制台输出中的任何异常情况,当这些操作失败时,您有时会从中得到线索。

这就是设备上的缓存路径:/var/mobile/Applications/F7A20BFE-EF4F-43B4-B120-72F532F08632/Library/Caches/highlightcaches当
writetodiskssuccess
为否时,您的
NSLog
打印了什么?