我在我的主线程中使用 NSProgressIndicator 在我运行整个方法时更新进度。现在,当我最终从不同的类文件中调用一个对象,并等待该对象返回到我的主线程的值时,我注意到 NSProgressIndicator 将消失。我知道这是因为主线程被阻塞,直到我从另一个对象获得返回值。
所以我的问题是在主线程中更新 UI 而不阻塞它并让其他对象在后台运行并根据需要将值返回给主线程的推荐方法是什么。我知道如何使用块,但不允许块操作返回值。我需要的是帮助这个伪代码的东西:
-(IBAction) main {
//Update progress indicator UI to show progress
//perform an call to another object from another class.
// wait till i get its return value.
//Update progress indicator UI to show progress
// Use this return value to do something.
//Update progress indicator UI to show progress
}
当调用另一个对象时,我注意到我已经完全消失了确定的 NSProgressIndicator,因为主线程被阻塞了。谢谢。