我已经在处理所有服务器请求的方法中实现了可达性功能。我可以通过NSLogs清楚地看到该函数完美地运行。然而,该方法从未有过"暂停",这意味着我无法使用UIAlertView而不崩溃程序。
也许我正在完全错误的方向上处理,但我找不到其他解决方法......
有人有想法如何以某种方式显示通知吗?
提前感谢
代码:
-(id) getJson:(NSString *)stringurl{
Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"];
NSLog(@"reached %d", reach.isReachable);
if (reach.isReachable == NO) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Passwords don't match."
message:@"The passwords did not match. Please try again."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}else{
id x =[self getJsonFromHttp:stringurl];
return x;
}
return nil;
}