我正在使用AFNetworking库,它使用块来处理您的结果,如下所示:
[httpClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *op, id response) {
//success clock
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//error block
}]
有没有代码块的使用方法?例如使用委托?如下所示:
[httpClient HTTPRequestOperationWithRequest:request delegate:self]
并在自课中:
-(void)afhttpSuccess:(AFHTTPRequestOperation*)op Response:(id)response {
//success method
}
-(void)afhttpError:(AFHTTPRequestOperation*)op Response:(NSError*)error {
//error method
}