performSelector不执行

时间:2016-01-06 10:46:11

标签: ios multithreading nsthread

这是我的代码,我是NSThread的新手,为什么这些代码不会执行?请帮助。

基本上我有一个viewcontroller,当按下按钮时我调用TESTC(), 你应该知道TESTC()是一个C函数。 提前谢谢。

@interface Worker : NSObject
@property (nonatomic, strong) NSThread *thread;
- (void)performTask1 : (void *)context;
@end

@implementation Worker

- (instancetype)init
{
    if (self = [super init]) {
        _thread = [[NSThread alloc] init];
    }
    return self;
}

- (void)performTask1 : (void *)context
{
    [self performSelector:@selector(Task1) onThread:self.thread withObject:(__bridge id _Nullable)(context) waitUntilDone:YES];
}

- (void)Task1
{
    NSLog(@"Task1 proceed");
}
@end


void TESTC()
{
    Worker *kelvin = [[Worker alloc] init];
    [kelvin performTask1:nil];
}

0 个答案:

没有答案
相关问题