-[NSMetadataQuery searchItems] is not effective for the results

Originator:marcin.krzyzanowski
Number:rdar://29611955 Date Originated:11/12/2016
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification: Reproducible:
 
Area:
CloudKit (iCloud)

Summary:
It is documented that -[NSMetadataQuery searchItems] property should define query's scope. 

> Use this method to scope the metadata query to a collection of existing URLs and/or metadata items. This array contains the NSURL and/or NSMetadataItem items to be searched.

However, the scope is not narrowed by the searchItems from a property. Not matter what valid URL is added to the list, it is ignored. Setting the same filter with the predicate works as expected.

Steps to Reproduce:
NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
[query setSearchItems:@[itemURL]];
[query setSearchScopes:@[NSMetadataQueryUbiquitousDocumentsScope]];
[query startQuery]

// wait for NSMetadataQueryGatheringProgressNotification

Expected Results:
The -[NSMetadataQuery results] array is narrowed to the searchItems defined for the query.

Actual Results:
-[NSMetadataQuery results] contains all items for the container.

Version:
iOS 10.1.1

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!