Alternatively, if your app targets iOS> = 4, you can use Grand Central Dispatch:
dispatch_async(dispatch_get_main_queue(), ^{
This is useful when your user logic cannot be easily expressed using separate selector and object arguments that accept the performSelect… methods.
To execute the block synchronously, use dispatch_sync() - but make sure that you are not currently executing in the main queue, or the GCD will block.
__block NSInteger alertResult;
source share