Afnetwork get json
按照官方教程获取了几个网上的免费json都不成功,发现acceptable contenttype 问题,修改好了
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"]; [manager GET:@"http://192.168.1.117:8888/hello.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }];
时间: 2024-10-16 11:14:28