我建立了一個AFNetworking HTTP Client 子類,並且注冊了HTTP操作為AFJSONRequestOperation
設置默認標題:
[self setDefaultHeader:@"Content-Type" value:@"application/json"];
[self setDefaultHeader:@"Accept" value:@"text/html"];
調用服務器:
[[TheAPIClient sharedClient] getPath:domain parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {
NSLog(@"%@", JSON);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"FAILED");
但是得到的結果是一堆數字:
<7b0d0a20 20224d65 6e755365 74223a20 7b0d0a20 20202022 4b617465 676f7269 53657422 3a205b0d 0a202020 2020207b 0d0a2020 20202020 20202245 6c656d65 6e745365 74223a20 5b0d0a20 20202020 20202020 207b0d0a 20202020 20202020 20202020 22496422 3a20312c 0d0a2020 20202020 20202020 2020224e 61766e22 3a202252 656a6520 636f636b 7461696c 222c0d0a 20202020 20202020 20202020 22426573 6b726976 656c7365 223a2022 52656a65 723f222c 0d0a2020 20202020 20202020 20202250 72697322 3a203134 392c0d0a 20202020 20202020 20202020 224b6174 65676f72 69536574 4964223a 20310d0a 20202020 20202020 20207d0d 0a202020 20202020 205d2c0d 0a202020 20202020 20224964 223a2031 2c0d0a20 20202020 20202022 4e61766e 223a2022 466f7272 6574222c 0d0a2020 20202020 20202245 6c656d65 6e745365 74496422 3a20312c 0d0a2020 20202020 2020224d 656e755f 4964223a >
}];
這是怎麼回事?應該怎麼解決?謝謝
NSString *responseString = [[NSString alloc] initWithData: JSON encoding:NSUTF8StringEncoding];
NSDictionary *weatherDic = [NSJSONSerialization JSONObjectWithData: JSON options:NSJSONReadingMutableLeaves error:&error];