Iphone Web Thread _WebThreadLockFromAnyThread
Perhaps one Iphone Guru can enlighten me...
I've been going line-by-line and eliminating any threads calls / NSInvocation's that use the UIKit, as a matter of fact, I have made 100% sure that NO UIKit crap gets called from any-where else except the MainThread I.E...
if([NSThread isMainThread])
{
blah....
Call UIKit Crap here!
and blah....
}
So far so good, but then after I created a thread to do a http POST (using LibCurl) I started getting this:
"void _WebThreadLockFromAnyThread(bool), 0x4d7bbe0: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread."
Like WTF...? I can't even Use Curl from a Thread, to do a Network Intensive Operation..? I just moved this damn thing, off the mainThread, to Comply with Their (Apple's) UIKit's strict, "Don't call any UIKit crap, except from the Main Thread...PERIOD or Else!!!"
So I move the "UiAlertView & UIActivityIndicator" back onto the main thread (No error messages before) and create a thread to do the curl POST operation... Now that I am in compliance, and then all of a sudden, I start getting this message...?
Can anyone explain where I am suppose to put th开发者_开发百科is Network intensive operation, which, by the way, will cause the any UIActivity Indicator's / UIAlertView's to freeze in their tracks...
Thanks in Advance...
[I am just a linux programmer in sheep's clothing]
Ok, The answer (Has nothing at all to do with Curl or some fictional notification to the main thread)
Anyone who gets this error, Don't think WEB Thread or Main Thread, THINK, UITextView or UIScrollView or any other view that might be getting passed off to your new thread.
My problem was a UITextView.text, that was being passed as an argument to the NEW thread... Hence "_WebThreadLockFromAnyThread(bool)"
So a simple fix was to copy it to a local NSString and pass that copy in the argument, to the new thread (I.E... Warning: UIKit should not be called from a secondary thread)
[NSThread detachNewThreadSelector: @selector(sendStuff:) toTarget: self withObject: self.textField.text];
When you see hoof prints, THINK horses, NOT Zebra's.
精彩评论