objective-c - 使用 UIAlertController 调用其包含函数
问题描述
我Reachability
用来检查 wifi 连接是否有任何变化。这将根据连接将变量wifiStatus
设置为 Y 或 N。这工作正常。
当应用程序启动时,我有一个setup
调用自身的函数,直到 wifiStatus 为 Y。
- (void)setup {
if([wifiStatus isEqualToString:@"Y"]) {
//go to another function;
}
else {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Wifi" message:@"You must be connected to the internet to complete set up." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"Try again" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[self setup];
}];
[alert addAction:alertAction];
[self presentViewController:alert animated:YES completion:nil];
}
}
它工作得很好我只是检查如果用户必须按Try again
多次我不会遇到任何类型的递归问题。