I do not know why there is a difference between iOS4
and iOS5
at this point. But your description of the user interface widget is consistent with the code you provided. The execution selector in the main thread does just that, executing the selector in the main thread, which is the thread you are calling from. Because of this parameter, waitUntilDone:
to NO
pointless, since it is not sent to another thread, it just works in order. You would probably get the results you want by simply replacing the order, like So:
[self dismissModalViewControllerAnimated:YES]; animate = true; [self performSelectorOnMainThread:@selector(processImage:) withObject:info waitUntilDone:NO];
But keep in mind that at best this would be risky since I assume that // processing of image
does not contain concurrency. I prefer blocks for concurrency. And besides, I like nested blocks to make concurrency easy to follow, for example:
-(void)doSomeStuffInBackground{ // Prepare for background stuff dispatch_async(dispatch_get_global_queue(0, 0), ^{ // Do background stuff dispatch_async(dispatch_get_main_queue(), ^{ // Update UI from results of background stuff }); }); }
So, with that in mind, I would suggest something like this:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ [self dismissModalViewControllerAnimated:YES]; [self processImage:info]; } -(void)processImage:(NSDictionary *)info{ animate = true; UIImage *image = nil; NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType]; dispatch_async(dispatch_get_global_queue(0, 0), ^{
This will unload the main work into the background thread so that the user interface remains responsive.
source share