iPhone 3.0 Development Glitches
I had a few glitches in the Helipad iPhone app when 3.0 rolled around. I’ve put the solution here to help those of you searching for the error message.
Helipad syncs to our web app and displays a syncing progress screen. I open this view in a new view controller like this:
SyncController *sync = [[SyncController alloc] initWithNibName:@"SyncController"
bundle:nil];
[self presentModalViewController:sync animated:YES];
The parent view displays a UIWebView, and the controller runs the sync process on another thread so the display can be updated with feedback. The problem was that updating UIWebView crashed the app:
bool _WebTryThreadLock(bool): Tried to obtain the web lock from a thread
other than the main thread or the web thread. This may be a result of calling
to UIKit from a secondary thread.
I can only assume that this was caused as part of the improvements to UIWebView’s performance. The crash actually occurred when the sync process called dismissModalViewControllerAnimated:. To resolve this, I called it on the main thread like this:
[self performSelectorOnMainThread:@selector(dismissSyncView)
withObject:nil
waitUntilDone:YES];</pre>
My method, dismissSyncView, looks like this:
- (void)dismissSyncView {
[self dismissModalViewControllerAnimated:YES];
// Other custom code goes here
}



blog comments powered by Disqus