我只是在尝试使用 AFNetworking 版本 2 的第一步。
由于新版本,现有的在线教程(如 Ray Wenderlich 的 afnetworking-crash-course)不再适用。
从 AFNetworking 2 迁移指南中,我得到了以下代码:
https://github.com/AFNetworking/AFNetwor …迁移指南
NSURL *URL = [NSURL URLWithString:@"http://example.com/foo.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
initWithRequest:request];
operation.responseSerializer = [AFJSONSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
} failure:nil];
[operation start];
此时我已经添加了导入
#import "AFNetworking.h"
到 .pch 文件。
问题:我总是收到错误消息,AFJSONSerializer 未声明。
我忘记了哪一步?
此致
坦率