, , , , . , Grand Central Dispatch (4.0+), NSOperation, performSelectorInBackground:.... / , .
: performSelectorInBackground:withObject: performSelectorOnMainThread:withObject:waitUntilDone:. - :
// -searchForString: is our search method and searchTerm is the string we are searching for
[self performSelectorInBackground:@selector(searchForString:) withObject:searchTerm];
Cocoa -searchForString: . , . :
- (void)searchForString:(NSString *)searchTerm
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *searchResults = ...
[self performSelectorOnMainThread:@selector(searchDidFinishWithResult:) withObject:searchResults waitUntilDone:YES];
[pool drain];
}
searchDidFinishWithResult: :
- (void)searchDidFinishWithResult:(NSArray *)searchResult
{
...
}
, , . , , , , . , , , (NSOperation ).