ここから AFNetworking をプロジェクトに統合しました。しかし、AFNetworking を使用してリクエストを取得すると、常に Failure ブロックに入ります。以下は私のコードです。ここで何が間違っているのか教えてください。
NSString *baseUrl = @"http://www.nactem.ac.uk/software/acromine/dictionary.py?sf=ETA";
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:baseUrl parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"%@",responseObject);
//Always it invoke the Failure block
}failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSHTTPURLResponse *response = error.userInfo[AFNetworkingOperationFailingURLResponseErrorKey];
NSInteger statusCode = response.statusCode;
NSLog(@"Error Code=%ld",statusCode);
NSLog(@"Desc=%@",response.description);
}];
注:- これは有効な URL です。 http://www.nactem.ac.uk/software/acromine/dictionary.py?sf=ETA
また、以下はエラーコードと説明です:-
Error Code 200
Error Description <NSHTTPURLResponse: 0x7fbab8509860> { URL: http://www.nactem.ac.uk/software/acromine/dictionary.py?sb=hmm } { status code: 200, headers {
Connection = close;
"Content-Type" = "text/plain; charset=UTF-8";
Date = "Wed, 20 Apr 2016 00:17:27 GMT";
Server = "Apache/2.2.15 (Scientific Linux)";
"Transfer-Encoding" = Identity;
} }