What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
- Subject: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
- From: 尹佳冀 <email@hidden>
- Date: Sun, 03 Feb 2013 15:41:37 +0800
Hi All
Does anyone can know what the difference between [NSOperationQueue
currentQueue] and
performSelectorOnMainThread, If I do some work use operation
on [NSOperationQueue mainQueue], the UI will not hang up, but if i
use performSelectorOnMainThread the UI will hang up
- (void) doTheThing
{
//Do do some work about 9~20 s
}
[self showIndicatorWithString:NSLocalizedString(@"Doing...", nil)];
// is a MBProgreessHUD, add a view then use a animation to show
//Case 4 not hang up, HUD show and can refresh, but the screen
cannot response user's touch
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(doTheThing)
object:nil];
[[NSOperationQueue mainQueue] addOperation:operation];
//Case 2 hang up, HUD not show
//[self doTheThing];
//Case 3 hang up, HUD not show
//[self performSelectorOnMainThread:@selector(doTheThing)
withObject:nil waitUntilDone:YES];
//Case 4 not hang up, HUD show and can refresh, but the screen
cannot response user's touch
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(doTheThing)
object:nil];
[[NSOperationQueue currentQueue] addOperation:operation];
--
Fykec Yin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden