Ios ASIHTTP正在使用块,由于未捕获异常而终止

Ios ASIHTTP正在使用块,由于未捕获异常而终止,ios,ios7,request,asihttprequest,unrecognized-selector,Ios,Ios7,Request,Asihttprequest,Unrecognized Selector,我在一个旧的iOS7项目中使用ASIHTT。因此,今天我将我的文件更新为ASITP的newets版本,并尝试使用using块,如上的示例所示。我的代码如下所示: NSURL *url = [NSURL URLWithString:@"URL To A Site That Returns A JSON String"]; __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request addReques

我在一个旧的iOS7项目中使用ASIHTT。因此,今天我将我的文件更新为ASITP的newets版本,并尝试使用using块,如上的示例所示。我的代码如下所示:

NSURL *url = [NSURL URLWithString:@"URL To A Site That Returns A JSON String"];
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request addRequestHeader:@"Accept" value:@"application/json"]; //Returneres som JSON
[request setRequestMethod:@"POST"];
[request setCompletionBlock:^{
    // Use when fetching text data
    NSString *responseString = [request responseString];

    // Use when fetching binary data
    NSData *responseData = [request responseData];
}];
[request setFailedBlock:^{
    NSError *error = [request error];
}];
[request startAsynchronous];
运行代码时,我会遇到以下异常:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ASIHTTPRequest setFailedBlock:]: unrecognized selector sent to instance 0x157529f0'
*** First throw call stack:
(0x2f17bf0b 0x39912ce7 0x2f17f837 0x2f17e137 0x2f0cd098 0x1262fd 0x125957 0x111fcf 0x319afa53 0x319af811 0x31ad758b 0x31ad741f 0x31ad72f7 0xe1c63 0x31ac97f3 0x31b7bcb3 0x31a2ae09 0x319a3b57 0x2f147039 0x2f1449c7 0x2f144d13 0x2f0af769 0x2f0af54b 0x3401c6d3 0x31a0e891 0xb147d 0x39e10ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
请注意,如果我进行同步调用,它会工作:但我需要这个调用是异步的


如果您能帮助解决此问题,我们将不胜感激。

Beaware的开发者已不再支持ASIHttpRequest,并且知道iOS 6及更高版本中的漏洞。如果可能的话,你应该使用一个库来处理netwerkt请求。嗯,好的:(.有什么建议吗?有流行的,而且很长时间没有更新。定期更新,非常流行。好的,很多。我会尝试最好看的:)