现在的位置: 首页 > 综合 > 正文

使用NSObject中的函数起线程

2018年02月13日 ⁄ 综合 ⁄ 共 1036字 ⁄ 字号 评论关闭

下面的这些函数是定义在NSObject中的,关于它们的具体含义,你可以在官方文档中找,或者google之,这里就不啰嗦了。

Sending Messages

下面给出一个例子:

- (IBAction)Start:(id)sender {
    [self performSelector:@selector(doSomething:)];
    //[self doSomething:nil];
    //[self per
    [self performSelectorInBackground:@selector(doSomething:) withObject:nil];
    
}

-(void)doSomething:(id)inputData
{
    if([NSThread isMainThread])
    {
        NSLog(@"in main thread");
        
    }
    else {
        NSLog(@"not in main thread");
    }
    NSLog(@"kkkkk");
}

转自:http://blog.csdn.net/nicktang/article/details/6872275#//apple_ref/occ/instm/NSObject/performSelector:withObject:afterDelay:

抱歉!评论已关闭.