2

Ok, so I have been at this for about 2 hours now.

I can get the following lines of code to run in the simulator, but I cannot get it to compile on the device and I dont know why.

I keep getting the compile error 'No visible @interface for 'NSThread' declares the selector 'start'. The error occurs on the line [t start];

Here is the code:

@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

Any help would be much appreciated. I think I am sitting to close to the trees to see the forrest here.

DrRocker
  • 655
  • 1
  • 7
  • 14

0 Answers0