このチュートリアルに従って、HTML リクエストを使用して基本的な iPhone アプリを作成しています。
チュートリアルでは、AFNetworking で AFJSONRequestOperation を使用しています。問題は、AFJSONRequestOperation がなくなった AFNetworking バージョン 2 を使用していることです。
したがって、もちろん、次のコード (チュートリアルの途中から、「Querying the 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];
私の質問は、AFNetworking 2.x で作業を続けることができるように、AFJSONRequestOperation を何に置き換えるかです。これをグーグルで検索したところ、他の誰もこの質問をしていないようです。