我在我的iOS项目中使用AFNetworking,这是我的代码:
NSURL *url = [NSURL URLWithString: [signinUrl stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:signinUrl parameters:dicParam success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSString *myString = [[NSString alloc] initWithData:operation.request.HTTPBody encoding:NSUTF8StringEncoding];
NSLog(@"Error: %@", myString);
}];
这段代码可以正确地与服务器建立连接,我收到了答案,但是我需要用他们的描述来捕获代码状态,我的意思是......抓住这样的东西:
status_code:406自定义消息
我可以获取状态代码,但它是一个整数,任何人都知道如何获取此自定义消息?