gpt4 book ai didi

Objective-C performSelectorInBackground - 调用的方法在哪里运行?

转载 作者:行者123 更新时间:2023-11-28 20:30:06 26 4
gpt4 key购买 nike

简单的问题:如果我这样做会发生什么:

- (void)viewDidLoad
{
[self performSelectorInBackground:@selector(myBGMethod) withObject:nil];
}

-(void)myBGMethod
{
[self myOtherMethod];
}

-(void)myOtherMethod
{
NSLog(@"This is not Inception");
//some more code here
}

NSLog()myOtherMethod 中的其他代码是在主线程还是在后台运行?

最佳答案

它将在后台线程中运行。

您可以通过在所有方法中调用 NSLog 来确认这一点。默认情况下,NSLog 沿着进程 ID (pid) 打印线程号。

关于Objective-C performSelectorInBackground - 调用的方法在哪里运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12493893/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com