Upgrade to the latest Xcode, encountered property synthesis related error when using afnetworking

Source: Internet
Author: User

Upgrade Xcode to the latest, when using afnetworking encountered the property synthesis related error, the following information:

Auto property synthesis won't synthesize property ' request ' because it's ' readwrite ' but it'll be synthesized ' reado Nly ' via another property

Auto property synthesis won't synthesize property ' response ' because it's ' readwrite ' but it'll be synthesized ' read Only ' via another property

Defined in Afhttprequestoperation:

@property (ReadWrite, nonatomic, strong) Nsurlrequest *request;

@property (ReadWrite, nonatomic, strong) Nshttpurlresponse *response;

This is the code that will make the request property appear warning. The reason is that because compiler reads sub-class, the request should clearly be a ReadOnly property (Super-class), but you have to set it as the read write property, so compile R doesn't know how to auto synthesis.

But you know the implementation of Super-class, will also change this property to ReadWrite, so you in the implementation of sub-class this write is not a problem. But compiler do not know Ah, this how to do?

You have to tell compiler, don't worry about it. So how do you tell compiler? What you need is @dynamic, it's a promise to compiler, promise it "although you don't know what to do right now, you'll know it at runtime." So just change the code to the following:

@implementation Afhttprequestoperation

@dynamic response;

@dynamic request;



@end

Upgrade to the latest Xcode, encountered property synthesis related error when using afnetworking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.