AFNetworking 2为新手迁移

Spr*_*iel 0 iphone xcode ipad afnetworking afnetworking-2

我正在尝试使用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];
Run Code Online (Sandbox Code Playgroud)

这时我已经添加了导入

#import "AFNetworking.h"
Run Code Online (Sandbox Code Playgroud)

到.pch文件.

问题:我总是收到错误消息,AFJSONSerializer是未声明的.

我忘记了什么步骤?

最好的祝福

坦率

Luc*_*rti 5

应该是AFJSONResponseSerializer,而不是AFJSONSerializer.