문제

I have succeeded uploading a file to iCloud, which can be seen within icloud space manager(but,what odd is the file name is 'unknown').

I also found a piece of code from apple's document

_query = [[NSMetadataQuery alloc] init];
[_query setSearchScopes:[NSArray arrayWithObjects:NSMetadataQueryUbiquitousDataScope, nil]];
[_query setPredicate:[NSPredicate predicateWithFormat:@"%K == '*.*'", NSMetadataItemFSNameKey]];
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(fileListReceived)
                           name:NSMetadataQueryDidFinishGatheringNotification object:nil];
[notificationCenter addObserver:self selector:@selector(fileListReceived)
                           name:NSMetadataQueryDidUpdateNotification object:nil];
[_query startQuery];
//

[super viewDidLoad];

-(void)fileListReceived 
{
NSArray* queryResults = [_query results];
for (NSMetadataItem* result in queryResults) {
    NSString* fileName = [result valueForAttribute:NSMetadataItemFSNameKey];
    NSLog(@"fileName = %@", fileName);
}
}

but the result is always 0, no matter NSMetadataQueryUbiquitousDataScope or NSMetadataQueryUbiquitousDocumentsScope.

I also know that icloud has backup function, so does backup has any relation with uploading file by app itself?

도움이 되었습니까?

해결책

In your predicate try to use "like" instead of "==".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top