objective-cxcodemacosspotlightnsmetadataquery

Setting batch parameters with NSMetadataQuery or MDQuery


It would be helpful if someone shares how batching a query is done using -

- (void)setNotificationBatchingInterval:(NSTimeInterval)timeInterval

when used with NSMetadataQuery or by using

void MDQuerySetBatchingParameters (
    MDQueryRef query,  
    MDQueryBatchingParams params
);

structure when used with MDQuery class.

My understanding of batching is that - NSMetadataQueryGatheringProgressNotification/kMDQueryProgressNotification observers are notified depending on the values given in timeInterval/MDQueryBatchingParams.

When I pass 0.001f to the value of timeInterval, I expected it to notify the method every 1msec which is not the case.


Solution

  • I found that these values when given to MDQueryBatchingParams structure worked the way I wanted except that max_num values were of no use. There were notifications every milli second so that I could control the results.

    MDQueryBatchingParams params;
    params.first_max_num = 100;
    params.first_max_ms = 1;
    params.progress_max_num = 1;
    params.progress_max_ms = 100;
    params.update_max_num = 100;
    params.update_max_ms = 100;