Tôi bắt đầu chơi với ARC và một trong những trải nghiệm đầu tiên tôi đang cố gắng thực hiện cuộc gọi HTTP tới một URL và lấy lại một số dữ liệu. Tất nhiên, các mã trạng thái HTTP là quan trọng với tôi, vì vậy có nghĩa là tôi đi đến tôi "goto" của việc sử dụng sendSynchronousRequest
như:NSURLConnection sendSynchronousRequest với ARC
NSError *error = [[NSError alloc] init];
NSHTTPURLResponse *responseCode = nil;
NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:responseCode error:error];
Với ARC cho phép tôi nhận được một lỗi biên dịch và cảnh báo trên rằng dòng cuối cùng.
lỗi:
Implicit conversion of an Objective-C pointer to 'NSURLResponse *__autoreleasing *' is disallowed with ARC
Implicit conversion of an Objective-C pointer to 'NSError *__autoreleasing *' is disallowed with ARC
file://localhost/Users/jason/Projects/test/Data/DataService.m: error: Automatic Reference Counting Issue: Implicit conversion of an Objective-C pointer to 'NSURLResponse *__autoreleasing *' is disallowed with ARC
file://localhost/Users/jason/Projects/test/Data/DataService.m: error: Automatic Reference Counting Issue: Implicit conversion of an Objective-C pointer to 'NSError *__autoreleasing *' is disallowed with ARC
Warnings:
Incompatible pointer types sending 'NSHTTPURLResponse *_strong' to parameter of type 'NSURLResponse *_autoreleasing *'
Incompatible pointer types sending 'NSError *_strong' to parameter of type 'NSError *_autoreleasing *'
Từ những gì tôi có thể nói việc thông qua tham chiếu là những gì đang rối tung này lên, nhưng tôi không chắc chắn những gì cách chính xác để giải quyết vấn đề này. Có cách nào "tốt hơn" để thực hiện nhiệm vụ tương tự với ARC không?
LOL ... phục vụ tôi để cố nghĩ sau những ngày nghỉ! –