Iphone Web Thread _WebThreadLockFromAnyThread

Perhaps one Iphone Guru can enlighten me ...

I took turns and eliminated any thread calls / NSInvocation that use UIKit, in fact, I made 100% sure that NO UIKit crap is called from anywhere except MainThread That is ...

if([NSThread isMainThread]) { blah.... Call UIKit Crap here! and blah.... } 

So far, so good, but then after I created the stream to do the http POST (using LibCurl) I started getting this:

"void _WebThreadLockFromAnyThread (bool), 0x4d7bbe0: Get a web lock from a thread other than the main thread or the web thread. UIKit should not be called from the secondary thread.

How is WTF ...? I can't even use Curl from Thread to do a network intensive operation.? I just moved this damn thing from mainThread to match their (Apple) UIKit strict: "Don't call any UIKit shit except from the main topic ... PERIOD or Else !!!"

So, I move the “UiAlertView and UIActivityIndicator” back to the main thread (with no error messages before) and create a thread to perform the POST operation with a swirl ... Now that I am fine, and suddenly I start receiving this message ...?

Can someone explain where I assume this intensive operation on the network, which, by the way, will cause any UIActivity / UIAlertView indicator to freeze ...

Thanks in Advance ...

[I'm just a Linux programmer in sheep's clothing]

+7
source share
1 answer

Ok, answer (has nothing to do with Curl or some fictitious notification of the main thread)

Anyone who gets this error, don’t think of the WEB Theme or Main Theme, THINK, UITextView or UIScrollView strong> or any other view that can be transferred to your new thread.

My problem was in UITextView.text, which was passed as an argument to NEW thread ... Therefore, "_ WebThreadLockFromAnyThread (bool)"

So, a simple solution was to copy it to a local NSString and pass this copy in the argument to a new thread (IE .. 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 Zebras.

+29
source

All Articles