0

我正在使用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
}
4

1 回答 1

3

不知道为什么委托 + 选择器范式更可取,但我制作了这个库,它简化了从具有该模式的 ASI 的过渡

或者,您始终可以在成功/失败回调中调用成功/失败方法。

于 2013-01-15T21:59:46.247 回答