gpt4 book ai didi

iphone - iCloud 集成警告

转载 作者:行者123 更新时间:2023-11-29 13:17:29 30 4
gpt4 key购买 nike

我正在尝试集成 iCloud。

一切正常,但当我尝试从 iCloud 读取文件时,我收到如下警告:

Foundation called mkdir("/var/mobile/Library/Mobile Documents/.ubd/peer-E8A60A8F-FB9D-8721-F47C-hdffgdfg-v23/ftr/(A Document Being Saved By XYZ)"), it didn't return 0, and errno was set to 1.

我获取数据的代码:

for (NSMetadataItem *item in results)
{
NSString *filename = [item valueForAttribute:NSMetadataItemDisplayNameKey];
NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
MyDocument *doc = [[MyDocument alloc] initWithFileURL:url];

[doc openWithCompletionHandler:^(BOOL success) {
if (success) {
NSData *file = [NSData dataWithContentsOfURL:url];

NSString *docDir = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"Import/iCloud"];
if (![[NSFileManager defaultManager] fileExistsAtPath:docDir])
[[NSFileManager defaultManager] createDirectoryAtPath:docDir withIntermediateDirectories:YES attributes:nil error:nil];

NSString *pdfFile = [docDir stringByAppendingPathComponent:filename];
if(![[NSFileManager defaultManager] fileExistsAtPath:pdfFile])
[[NSFileManager defaultManager] createFileAtPath:pdfFile contents:file attributes:nil];

NSLog(@"Successfully loaded data from cloud file name %@", filename);
}
else
{
NSLog(@"Failed to load data");
}
}];

}
}

最佳答案

看起来您在 iCloud 中有一个部分写入的文件(基于错误中的 A Document Being Saved By XYZ),并且您的元数据查询已将其返回给您,因为它也匹配文件名。几周前我遇到了类似的情况,并通过使用文件的确切路径解决了这个问题,如:

NSString *filepath = [containerURL.path stringByAppendingPathComponent:@"MyFileName"];

NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K == %@", NSMetadataItemPathKey, filepath];
[query setPredicate:pred];

关于iphone - iCloud 集成警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15338371/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com