想象一下,我想在后台调用这个方法。
- (void)loadView
{
[super loadView];
//Make a button which will fire the "buttonClicked" method
//Make my own uitableview.
//Fire method: "theBackGroundMethod" in the background.
}
我对含糊不清感到抱歉,但我会尽量做到清楚。以下是我想要做的。我有一个视图,但它上面有这个按钮和一个空的 UITableView。然后我希望BackGroundMethod 运行背景,在运行时我希望能够单击按钮并触发buttonClicked 方法,该方法会将数据发送到UITableView。
以下我尝试了负面结果:
[self performSelectorInBackground:@selector(theBackGroundMethod) withObject:nil];
这将启动BackGroundMethod,但它不会加载我从服务器询问的数据。
[self performSelectorOnMainThread:@selector(theBackGroundMethod) withObject:nil waitUntilDone:NO];
这会启动BackGroundMethod,但由于某种原因它不允许我单击按钮,它允许单击按钮,但是我在方法触发点击时所做的每一个动作都放在它后面的队列中,所以只有当backgroundmethod完成了我按下按钮的 x 次处理。
有谁知道什么可能会阻止使用上述任何 performSelector 函数以及如何解决它们。或者有一个完整的(也许更好的)想法..?