I'm utilizing MBProgressHUD
in my project. I'm using the method showWhilePerformingSelector:
which is calling a method which utilizes NSURLConnection
. I read in another Stack Overflow question that people were having trouble using NSURLConnection
in a secondary thread because the thread would be killed before the delegate methods could be fired.
In essence, the question is, does MBProgressHUD
's showWhilePerformingSelector:
method run the selected method on a different thread? If so, how would I go about utilizing that main thread to run my NSURLConnection
?
Which version of MBProgressHUD
are you using? At v0.4 (the last on), there is no such method. Instead is showWhileExecuting
, which says:
/**
* Shows the HUD while a background task is executing in a new thread, then hides the HUD.
*
* This method also takes care of NSAutoreleasePools so your method does not have to be concerned with setting up a
* pool.
*
* @param method The method to be executed while the HUD is shown. This method will be executed in a new thread.
* @param target The object that the target method belongs to.
* @param object An optional object to be passed to the method.
* @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use
* animations while disappearing.
*/
- (void)showWhileExecuting:(SEL)method
onTarget:(id)target
withObject:(id)object
animated:(BOOL)animated;
What you should do is show just the HUD and remove it when delegates are fired. You should run the connection, not the Improves formatting.. Everything will be OK as long as you use asynchronous connections.
Something like this.