Upgrade xcode to the latest version. When AFNetworking is used, an error related to property synthesis occurs, xcodeafnetworking.

Source: Internet
Author: User

Upgrade xcode to the latest version. When AFNetworking is used, an error related to property synthesis occurs, xcodeafnetworking.
Upgrade Xcode to the latest version. When AFNetworking is used, an error related to property synthesis is encountered. The error message is as follows:

Auto property synthesis will not synthesize property 'request' because it is 'readwrite' but it will be synthesized 'readonly' via another property

Auto property synthesis will not synthesize property 'response' because it is 'readwrite' but it will be synthesized 'readonly' via another property

AFHTTPRequestOperation defines:

@ Property (readwrite, nonatomic, strong) NSURLRequest * request;

@ Property (readwrite, nonatomic, strong) NSHTTPURLResponse * response;

This Code will make the request property appear warning. The reason is that when compiler reads sub-class, it will find that the request should be a readonly property (in super-class), but you need to set it as read write property, therefore, compiler does not know how to auto synthesis.

However, you know that the super-class implementation will also change this property to readwrite, so there will be no problem in the sub-class implementation. But compiler does not know. What should I do?

You need to tell compiler that you don't have to worry about it. How can we tell compiler? What you need is @ dynamic, which is a "Promise" to compiler, and promises it "although you don't know what to do now, but you will know it at runtime 」. So you just need to change the code to the following:

@ Implementation AFHTTPRequestOperation

@ Dynamic response;

@ Dynamic request;



@ End

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.