u014297278
松鼠大作战
2016-05-31 08:35

ios http网络请求,返回 null

5

图片说明
代码如图,该接口在浏览器中能正常访问,但在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条回答

为你推荐

换一换