iCloud错误“操作无法完成.(LibrarianErrorDoman错误10-无法配置集合.) [英] iCloud Error "The operation couldn't be completed. (LibrarianErrorDoman error 10 - Unable to configure the collection.)"

查看:72
本文介绍了iCloud错误“操作无法完成.(LibrarianErrorDoman错误10-无法配置集合.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i want to migrate my existing app to iCloud.

在尝试学习操作时,我尝试了一个示例应用程序,该应用程序已按照演示中的描述进行了工作(如iTunes stanford大学课程的第17讲所示).

in my attempt to learn what to do, i have tried a sample app that has worked as described in the demo (as seen in lecture 17 of the iTunes stanford university course).

遇到此问题的人可以帮助我诊断我为使以下操作失败而搞砸了哪一步?这基本上是在告诉我没有要查询的数据吗?还是发生其他未正确配置的事情?

can someone who has had this problem help me diagnose what step i messed up to cause the following to fail? is this just telling me basically that there's no data to query? or is there something else going on that i haven't properly configured?

我在控制台中得到以下内容(在我调用 [self.iCloudQuery startQuery];

i am getting the following in my console (which occurs in the code below immediately after i call [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.

i created a development provisioning profile that has iCloud turned on on iTunes connect.

我启用了权利.这里是内容:

i turned on entitlements. here are the contents:

该代码直接来自斯坦福大学iTunes讲座:

the code is straight from the Stanford University iTunes lectures:

#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,该错误就会停止在我的日志中发生.

for anyone else running into this … apparently, this is the error that occurs when you haven't enabled iCloud on the device on which you are testing. once i enabled iCloud on the device, the error stopped occurring in my log.

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

and so now i know what error to check for in order to present the user with a dialog saying "connecting to iCloud won't work until you sign up for iCloud in the system preferences".

这篇关于iCloud错误“操作无法完成.(LibrarianErrorDoman错误10-无法配置集合.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆