3
我已經在處理所有服務器請求的方法中實現了Reachability功能。我可以通過NSLog看到該函數完美工作。但是在方法中從來沒有「暫停」,這意味着我不能在不崩潰程序的情況下使用UIAlertView。爲什麼在顯示UIAlertView時應用程序崩潰?
我可能在這個可以去完全錯誤的方式,但我無法找到任何東西...
有誰知道如何獲得通知以某種方式表明的想法?
在此先感謝
CODE:
-(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;
}
您能否至少發佈標題引用的「函數」的全部內容?希望看到更多的代碼 - 也許更清晰的描述。 – sean
完成。雖然我不認爲這會對額外的部分產生太大的幫助......但這個想法是讓我能夠在沒有程序崩潰的情況下顯示UIAlertView。有沒有辦法「暫停」應用程序,直到警報框被解除?或者我應該對問題採取完全不同的方法? – Tom
你的代碼是否用那個空的return來編譯? [alert show]後的聲明?應該返回一些東西,因爲編譯器正在尋找你返回一個(id)。 – sean