【问题标题】:call delegate method if property changes如果属性更改,则调用委托方法
【发布时间】:2011-11-11 00:01:52
【问题描述】:

我使用带有对象映射的 RestKit。这运行 asyncronus 并在从服务器接收数据后更新对象。

关键是,我需要通知另一个类一个对象的属性发生了变化。

现在我遇到了一个错误:

bool _WebTryThreadLock(bool), 0x1ae420: 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...

我试图覆盖该属性的设置器,但看起来该属性是在另一个线程中设置的,而不是在主线程中。在那里调用代理不起作用。

我能做些什么来解决这个问题?

感谢任何帮助!

【问题讨论】:

    标签: ios delegates nsthread setter


    【解决方案1】:

    也许你需要这样发送消息:

    [obj performSelectorOnMainThread:@selector(method)]

    【讨论】:

    • 谢谢!需要在我的对象的 setter 方法中使用[delegate performSelectorOnMainThread:@selector(method)];。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-06
    • 2011-07-23
    • 1970-01-01
    • 2017-07-07
    相关资源
    最近更新 更多