Pergunta

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?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top