У меня есть такой код (я пытаюсь открыть документы из облака):
NSPredicate *pred = [NSPredicate predicateWithFormat:@"%K ENDSWITH '.card'", NSMetadataItemFSNameKey];
NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
[query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
[query setPredicate:pred];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(queryDidFinishGathering:)
name:NSMetadataQueryDidFinishGatheringNotification
object:query];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(queryDidStartGathering:)
name:NSMetadataQueryDidStartGatheringNotification
object:query];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(queryDidUpdate:)
name:NSMetadataQueryDidUpdateNotification
object:query];
[query startQuery];
// ========================
- (void)queryDidFinishGathering:(NSNotification *)notification {
NSMetadataQuery *query = [notification object];
[query disableUpdates];
[query stopQuery];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSMetadataQueryDidFinishGatheringNotification
object:query];
for (NSMetadataItem* item in [query results]) {
NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
BCCardDocument *doc = [[[BCCardDocument alloc] initWithFileURL:url] autorelease];
[doc openWithCompletionHandler:^(BOOL success) {
if (success) {
NSLog(@"%@", doc.card.number);
}
}];
}
}
Но success Аргумент блока завершения openWithCompletionHandler всегда равен NO.Что может быть причиной этого?