Interface 对于';没有可见的@界面;NSThread';声明选择器';启动';
好的,我已经做了两个小时了 我可以在模拟器中运行以下代码行,但我无法在设备上编译,我不知道为什么 我一直收到编译错误“No visible@interface for'NSThread”声明选择器“start”。错误发生在[t start]行 代码如下:Interface 对于';没有可见的@界面;NSThread';声明选择器';启动';,interface,nsthread,visible,Interface,Nsthread,Visible,好的,我已经做了两个小时了 我可以在模拟器中运行以下代码行,但我无法在设备上编译,我不知道为什么 我一直收到编译错误“No visible@interface for'NSThread”声明选择器“start”。错误发生在[t start]行 代码如下: @interface FMThread : NSObject { @private NSCondition *waitCondition; } @property (copy) void (^block)(void); + (void)
@interface FMThread : NSObject {
@private
NSCondition *waitCondition;
}
@property (copy) void (^block)(void);
+ (void)runInSeparateThread:(void (^)(void))block;
@end
@implementation FMThread
+ (void)runInSeparateThread:(void (^)(void))block
{
FMThread *thread = [[FMThread alloc] init];
thread.block = block;
thread->waitCondition = [[NSCondition alloc] init];
[thread->waitCondition lock];
NSThread *t = [[NSThread alloc]initWithTarget:thread selector:@selector(threadMain) object:nil];
[t start];
[thread->waitCondition wait];
[thread->waitCondition unlock];
}
- (void)threadMain
{
@autoreleasepool {
self.block();
[waitCondition broadcast];
}
}
@end
任何帮助都将不胜感激。我想我是坐在靠近树木的地方看福勒斯特山的