【发布时间】:2014-02-13 04:11:56
【问题描述】:
我正在制作一个带有 HTML 请求的基本 iPhone 应用程序,遵循 this tutorial.
本教程让我在 AFNetworking 中使用 AFJSONRequestOperation。问题是,我使用的是 AFNetworking 版本 2,它不再具有 AFJSONRequestOperation。
所以,当然,这段代码(大约在教程的一半,在标题“查询 iTunes Store Search API”下)无法编译:
NSURL *url = [[NSURL alloc]
initWithString:
@"http://itunes.apple.com/search?term=harry&country=us&entity=movie"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation =
[AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@", JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response,
NSError *error, id JSON) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[operation start];
我的问题是,我应该用什么替换 AFJSONRequestOperation 才能继续使用 AFNetworking 2.x?我用谷歌搜索了一下,发现似乎没有其他人在问这个问题。
【问题讨论】:
标签: ios objective-c afnetworking afnetworking-2 afjsonrequestoperation