我在我的項目中使用AFNetworking
以從REST API獲取數據。 但是,當我使用Github中描述的方法時,我得到了警告。dataTaskWithRequest:completionHandler:已棄用
這裏是我的代碼:
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
NSURLRequest *request123 = [NSURLRequest requestWithURL:URL];
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request123 completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[dataTask resume];
我的項目支持的iOS 7.0及以上。
我的Xcode版本7.3.1
有沒有什麼辦法可以克服這個警告?
你能不能請在這裏發表您的警告? –
:'dataTaskWithRequest:completionHandler:'已棄用 – Himanth
@ vadian同意。它在我身邊工作。 –