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