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