我使用 getPath 方法调用我的网络服务,如下所示:
[[AFTwitterAPIClient sharedClient] getPath:@"GetWineCategoryList"
parameters:parameters success:^(AFHTTPRequestOperation *operation, id JSON) {
NSLog(@"JSON = %@",JSON);
NSMutableArray *mutableTweets = [NSMutableArray arrayWithCapacity:[JSON count]];
for (NSDictionary *attributes in mutableTweets) {
Tweet *tweet = [[Tweet alloc] initWithAttributes:attributes];
[mutableTweets addObject:tweet];
}
if (block) {
block([NSArray arrayWithArray:mutableTweets], nil);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (block) {
block([NSArray array], error);
}
}];
它始终输出为 NSData。如果我将此 NSData 转换为字符串,我会得到一个 JSON 字符串。
JSON = <5b7b2243 61746567 6f72794e 616d6522 3a224f54 48455222 7d2c7b22 43617465 676f7279 4e616d65 223a2252 4544227d 2c7b2243 61746567 6f72794e 616d6522 3a22524f 5345227d 2c7b2243 61746567 6f72794e 616d6522 3a225748 49544522 7d5d>
为什么它不会转换为 NSArray?