Ios NSMetadataQuery在未首先调用stopQuery的情况下被解除分配?
我在运行应用程序时打印此日志消息时遇到问题Ios NSMetadataQuery在未首先调用stopQuery的情况下被解除分配?,ios,objective-c,macos,Ios,Objective C,Macos,我在运行应用程序时打印此日志消息时遇到问题 <NSMetadataQuery: 0x6000000f1200> is being deallocated without first calling -stopQuery. To avoid race conditions, you should first invoke -stopQuery on the run loop on which -startQuery was called 对于Dealoc [self.query d
<NSMetadataQuery: 0x6000000f1200> is being deallocated without first calling -stopQuery. To avoid race conditions, you should first invoke -stopQuery on the run loop on which -startQuery was called
对于Dealoc
[self.query disableUpdates];
[self.query stopQuery];
我可能遗漏了什么有人帮我弄清楚
非常感谢您的帮助
self.query = [[MetadataQuery alloc] init];
self.query.sortDescriptors = @[[[NSSortDescriptor alloc] initWithKey:(id)kMDItemFSName ascending:YES]];
self.query.predicate = SearchPredicateForType(type);
self.query.delegate = self;
self.query.searchScopes = @[_searchURL.absoluteString];
self.query.notificationBatchingInterval = 10.0;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(metadataQueryDidFinishGathering_Notification:) name:NSMetadataQueryDidFinishGatheringNotification object:self.query];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(metadataQueryDidUpdate_Notification:) name:NSMetadataQueryDidUpdateNotification object:self.query];
[self.query disableUpdates];
[self.query stopQuery];
(void)metadataQueryDidFinishGathering_Notification:(NSNotification *)note {
NSLog(@"type %@", @(_type));
NSMetadataQuery *q = note.object;
if(![q.searchScopes containsObject:_searchURL.absoluteString]) {
NSLog(@"MISMATCH %@ %@", q.searchScopes, _searchURL);
// return;
}
[q disableUpdates];
[q stopQuery];
[self getTotalSizeOfQuery];
}