0
我正在嘗試使用ASIHTTPrequest。但是當我運行我的代碼時,出現以下錯誤消息。使用ASIHTTPRequest時發現錯誤
什麼錯在我的代碼,請幫助我,謝謝
域= ASIHTTPRequestErrorDomain代碼= 6「無法獲得所需的請求的代理服務器上的信息 」的UserInfo = 0x6043490 {NSLocalizedDescription =無法獲得代理服務器上的信息 需要請求}
下面是我的源代碼
- (void)viewDidLoad {
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startSynchronous];
[super viewDidLoad];
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSLog(@"Error %@", [request error]);
if ([request error])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Fail."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
}
這不是特定於您的問題,可能實際上並沒有解決它,但是您應該在''viewDidLoad''方法中將'[super viewDidLoad]'放在頂部。你是否按照說明如何設置? http://allseeing-i.com/ASIHTTPRequest/Setup-instructions –
這是否發生在模擬器和/或設備? – thomas
看來你沒有互聯網連接(Open proxy)在代碼中調用該網站鏈接。如果您在系統Safari瀏覽器中打開代理,那麼它將在模擬器中工作。 – user198725878