In my application, I have a UITableViewController that loads calculated data from my master data store. This can take quite a while and hang the main thread, so to give the user visual feedback, I installed the MBProgressHUD widget, which will show a progress indicator (only the spinning wheel), while the calculation method works in a separate thread.
This is great, except that the user can still exit the UITableViewController if he considers that it takes too long. Of course, this is good, except that when a separate thread completes its work, it still tries to call its delegate (UITableViewController) to hide the MBProgressHUD. This results in a crash, since the user has already left the UITableViewController, he has dealloc 'd and release ' d.
MBProgressHUD has the following code to stop this:
if(delegate != nil && [delegate conformsToProtocol:@protocol(MBProgressHUDDelegate)]) { if([delegate respondsToSelector:@selector(hudWasHidden)]) { [delegate performSelector:@selector(hudWasHidden)]; } }
However, my application somehow still works with this internal code ( [delegate performSelector:@selector(hudWasHidden)] ), even though the UITableViewController completely disappeared - this caused the application to crash.
Any suggestions? I do not work with NSZombiesEnabled .
Jason source share