Iphone Web 线程 _WebThreadLockFromAnyThread

发布于 2024-11-15 00:10:43 字数 814 浏览 2 评论 0原文

也许一位 Iphone Guru 可以启发我......

我一直在逐行进行并消除使用 UIKit 的任何线程调用/ NSInitation,事实上,我已经 100% 确定没有 UIKit 废话被调用除了主线程之外的任何地方 IE..

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

到目前为止一切顺利,但是在我创建了一个线程来执行http POST之后(使用LibCurl) 我开始得到这个:

“void _WebThreadLockFromAnyThread(bool),0x4d7bbe0:从主线程或Web线程之外的线程获取Web锁。不应从辅助线程调用UIKit。”

喜欢搞什么……?我什至不能使用线程中的 Curl 来执行网络密集型操作..? 我只是把这个该死的东西从主线程移开,以遵守他们(苹果)UIKit 的严格规定,“不要称任何 UIKit 为废话,除了主线程......期间或其他!!!”

因此,我将“UiAlertView & UIActivityIndi​​cator”移回主线程(之前没有错误消息)并创建一个线程来执行curl POST 操作... 现在我已经遵守了,然后突然间,我开始收到此消息......?

任何人都可以解释一下我应该把这个网络密集型操作放在哪里,顺便说一句,这将导致任何 UIActivity Indicators / UIAlertView's 冻结在他们的轨道上...

提前致谢...

[我只是一个 linux 程序员羊皮]

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 this 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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2024-11-22 00:10:43

好的,答案(与 Curl 或主线程的一些虚构通知无关)

任何收到此错误的人,不要认为 WEB 线程或 Thread、THINK、UITextViewUIScrollView 或任何其他可能传递到新线程的视图。

我的问题是 UITextView.text,它作为参数传递给新线程......
因此 "_WebThreadLockFromAnyThread(bool)"

因此,一个简单的修复方法是将其复制到本地 NSString 并将该副本传递到参数中,传递给新线程(IE .. 警告:不应从辅助线程调用 UIKit

[NSThread detachNewThreadSelector: @selector(sendStuff:) toTarget: self withObject: self.textField.text];

当您看到蹄印,想想马,而不是斑马。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文