【发布时间】:2014-05-07 13:04:53
【问题描述】:
我对执行方法的顺序有疑问。
if (indexPath.row == 2) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Data will be downloaded"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
if([app getData]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Data is downloaded."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
当我运行这段代码 sn-p 时,我想首先显示一个警报视图。但是,它会在显示警报视图之前调用getData 方法。一旦getData方法完成,alertView就来到了窗口。
我该如何纠正这个问题?
【问题讨论】:
-
[alert show];被异步调用。这就是为什么它立即调用[app getData]。
标签: ios methods uialertview