Reputation: 1011
I want to do some action on a thread using the following API, so strange selector poiOneBoxSearch hasn't been invoked, why? Any mistake on the code? Thanks.
- (void)poiOneBoxSearch{
[self poiOneBoxSearcWithQueryString:@"coffee" isFinished:YES];
}
- (void)test1{
NSThread* thread = [[NSThread alloc] init];
[self performSelector:@selector(poiOneBoxSearch)
onThread:thread
withObject:nil
waitUntilDone:YES];
[thread release];
}
Upvotes: 1
Views: 1186
Reputation: 7733
[self performSelectorInBackground:@selector(poiOneBoxSearch) withObject:nil];
- (void) poiOneBoxSearch{
@autoreleasepool {
[self poiOneBoxSearcWithQueryString:@"coffee" isFinished:YES];
} }
The most important thing that you have to keep in mind is that since this method creates a thread on the given selector, the selector must have an autorelease pool just like any other thread in a reference-counted memory environment.
Upvotes: 0
Reputation: 6067
If You want use performSelector Method You should Read below Link ,I Think You missed SOmething
If Not you may Use Below Code.
Try This
- (void)test1{
[NSThread detachNewThreadSelector:@selector(poiOneBoxSearch) toTarget:self withObject:nil];
}
Upvotes: 2
Reputation: 16714
Try this:
[self performSelectorInBackground:@selector(poiOneBoxSearch) withObject:nil waitUntilDone:YES];
Upvotes: 0