gpt4 book ai didi

ios - iCloud错误“操作无法完成。 (LibrarianErrorDoman错误10-无法配置集合。)”

转载 作者:行者123 更新时间:2023-12-01 18:28:00 24 4
gpt4 key购买 nike

我想将现有应用程序迁移到iCloud。

在尝试做些什么的过程中,我尝试了一个示例应用程序,该应用程序已按照演示中的说明进行了工作(如iTunes斯坦福大学 class 的第17讲所示)。

遇到此问题的人可以帮助我诊断出我弄错了什么步骤而导致以下操作失败?这基本上是在告诉我没有要查询的数据吗?还是发生其他未正确配置的事情?

我在控制台中得到以下信息(在我调用[self.iCloudQuery startQuery];后立即在下面的代码中发生

item update error: 0, Error Domain=LibrarianErrorDomain Code=10 "The operation couldn’t be completed.
(LibrarianErrorDomain error 10 - Unable to configure the collection.)" UserInfo=0x11ee00 {NSDescription=Unable to
configure the collection.}

我创建了一个开发配置文件,该文件已在iTunes Connect上打开了iCloud。

我打开了权利。这里是内容:

该代码直接来自斯坦福大学iTunes讲座:
#import "DocumentViewController.h"

@interface DocumentViewController ()
@property (strong, nonatomic) NSArray* documents; // of NSURLs
@property (strong, nonatomic) NSMetadataQuery* iCloudQuery;
@end

@implementation DocumentViewController
@synthesize documents = _documents;
@synthesize iCloudQuery = _iCloudQuery;

- (void)setDocuments:(NSArray*)documents {
// always sort documents alphabetically
documents
= [documents sortedArrayUsingComparator:^NSComparisonResult(NSURL* url1, NSURL* url2) {
return [[url1 lastPathComponent] caseInsensitiveCompare:[url2 lastPathComponent]];
}];
if (![documents isEqualToArray:_documents])
{
_documents = documents;
[self.tableView reloadData];
}
}

- (NSMetadataQuery*)iCloudQuery {
if (!_iCloudQuery)
{
_iCloudQuery = [[NSMetadataQuery alloc] init];
_iCloudQuery.searchScopes
= [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope];
_iCloudQuery.predicate
= [NSPredicate predicateWithFormat:@"%K like '*'", NSMetadataItemFSNameKey];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processCloudQueryResults:)
name:NSMetadataQueryDidFinishGatheringNotification
object:_iCloudQuery];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processCloudQueryResults:)
name:NSMetadataQueryDidUpdateNotification
object:_iCloudQuery];
}
return _iCloudQuery;
}

#pragma mark - private implementation

- (NSURL*)iCloudURL {
return [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
}

- (NSURL*)iCloudDocumentsURL {
return [self.iCloudURL URLByAppendingPathComponent:@"Documents"];
}

- (NSURL*)filePackageURLForCloudURL:(NSURL*)url
{
if ([url.path hasPrefix:self.iCloudDocumentsURL.path])
{
NSArray* iCloudDocumentsURLComponents = self.iCloudDocumentsURL.pathComponents;
NSArray* urlComponents = url.pathComponents;
if (iCloudDocumentsURLComponents.count < urlComponents.count)
{
NSRange newRange = NSMakeRange(0, iCloudDocumentsURLComponents.count+1);
urlComponents = [urlComponents subarrayWithRange:newRange];
url = [NSURL fileURLWithPathComponents:urlComponents];
}
}
return url;
}

- (void)processCloudQueryResults:(NSNotification*)notification
{
[self.iCloudQuery disableUpdates];
NSMutableArray* documents = [NSMutableArray array];
NSUInteger resultCount = self.iCloudQuery.resultCount;
for (NSUInteger i = 0; i < resultCount ; ++i)
{
NSMetadataItem* item = [self.iCloudQuery resultAtIndex:i];
NSURL* url = [item valueForAttribute:NSMetadataItemURLKey];
url = [self filePackageURLForCloudURL:url];
[documents addObject:url];
}
self.documents = documents;
[self.iCloudQuery enableUpdates];
}

#pragma mark - overrides

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (![self.iCloudQuery isStarted])
[self.iCloudQuery startQuery];
[self.iCloudQuery enableUpdates];
}

- (void)viewWillDisappear:(BOOL)animated {
[self.iCloudQuery disableUpdates];
[super viewWillDisappear:animated];
}

最佳答案

对于遇到此问题的其他人……显然,这是您没有在要测试的设备上启用iCloud时发生的错误。一旦我在设备上启用了iCloud,该错误就会停止在我的日志中发生。

因此,现在我知道要检查什么错误才能向用户显示一个对话框,提示您“在系统首选项中注册iCloud之前,无法连接到iCloud”。

关于ios - iCloud错误“操作无法完成。 (LibrarianErrorDoman错误10-无法配置集合。)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11515986/

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