*Edited : nothing wrong with the below code. In the XIB file, i dump in a UIWebView. Never set any delegate, never do anything with that UIWebView. It just crashes. Removing the UIWebView, everything works fine again. I use Automatic Reference Counting, and i think there's a bug with UIWebView.
My app crashes and here's the message :
Here's what my code look like :
Here's the situations :
MyViewController is pushed into a navigation controller.
- When i go to MyViewController, stay there for a while until doSmth finishes. Then everything is fine.
- If i go to MyViewController, then quickly tap "Back", after a while (which i believe is when doSmth finishes), app crashes and it throws the message.
From what i understand, it should not be because of accessing UI from background thread, because :
- I'm sure i don't access UI in doSmth
- If it's the case, then app should crash for both situations.
So why it only crashes when i already tap "Back" button ?
My app crashes and here's the message :
Code:
bool _WebTryThreadLock(bool), 0x8213c10: 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. Crashing now...
Here's what my code look like :
Code:
@implementation MyViewController
- (void) viewDidLoad {
[super viewDidLoad];
[NSThread detachNewThreadSelector:@selector(doSmth) toTarget:self withObject:nil];
}
- (void) doSmth {
// Do something here and don't update the UI
}
Here's the situations :
MyViewController is pushed into a navigation controller.
- When i go to MyViewController, stay there for a while until doSmth finishes. Then everything is fine.
- If i go to MyViewController, then quickly tap "Back", after a while (which i believe is when doSmth finishes), app crashes and it throws the message.
From what i understand, it should not be because of accessing UI from background thread, because :
- I'm sure i don't access UI in doSmth
- If it's the case, then app should crash for both situations.
So why it only crashes when i already tap "Back" button ?
Last edited: