【问题标题】:how to pass NSthread function from one view to another view如何将 NSthread 函数从一个视图传递到另一个视图
【发布时间】:2011-10-25 11:50:01
【问题描述】:

我正在使用NSThread

例如:

NSThread *driverThread = [[NSThread alloc] initWithTarget:self selector:@selector(**pingHomeThread**) object:nil];

[driverThread start]; 

in AppDelegate.m i want to execute  **pingHomeThread** function in another view like myExample.m as 
-(void) pingHomeThread{
}

我该如何实现这个?

【问题讨论】:

  • 良好的格式是你的朋友。
  • 请注意,从主线程之外更新任何 UIKit 元素可能会导致更新延迟和不可预知的行为。

标签: objective-c ios4 iphone-sdk-3.0


【解决方案1】:

只是改变目标(我不知道你的**是否在那里做,但他们不应该),即改变

NSThread *driverThread = [[NSThread alloc] initWithTarget:self selector:@selector(pingHomeThread) object:nil];

NSThread *driverThread = [[NSThread alloc] initWithTarget:yourOtherView selector:@selector(pingHomeThread) object:nil];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多