松鼠大作战
2016-05-31 08:35
采纳率: 66.7%
浏览 1.6k
已采纳

ios http网络请求,返回 null

图片说明
代码如图,该接口在浏览器中能正常访问,但在xcode里显示如图。xcode里其他接口正常
下面是代码

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
manager.requestSerializer.timeoutInterval = 20.f;
[manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/plain", @"text/html", nil];
NSString *urlStr = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@" %@",urlStr);
[manager POST:urlStr parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
// NSLog(@"suc: %@", string);
NSDictionary *dicRoot = [[[SBJsonParser alloc]init] objectWithString:string];
NSString *desc = [dicRoot objectForKey:@"desc"];

    NSDictionary *dicRoot2 = [[[SBJsonParser alloc]init] objectWithString:desc];
  //  verify = [dicRoot2 objectForKey:@"verify"];
    //verify是获取到的被加密的验证码

    NSLog(@"suc--: %@", desc);


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

3条回答 默认 最新

相关推荐 更多相似问题