1, the network request should build a request model according to Http://www.cocoachina.com/ios/20160509/16146.html finishing
@interface yaapibaserequestdatamodel:nsobject/*** Network request parameter */@property ( Nonatomic, Strong) NSString *ap Imethodpath; Network request Address @property (nonatomic, assign) Yaservicetype servicetype; Server Identity @property (nonatomic, strong) Nsdictionary *parameters; Request parameter @property (nonatomic, assign) Yaapimanagerrequesttype RequestType; Network request Mode @property (nonatomic, copy) Completiondatablock Responseblock; Request Landing callback//upload//upload File@property (nonatomic, strong) NSString *datafilepath; @property (nonatomic, Strong) NSString *dataname; @property (nonatomic, strong) NSString *filename; @property (nonatomic, strong) NSString *mimetype;// download//Download file//progressblock@property (nonatomic, copy) Progressblock Uploadprogressblock; @property ( nonatomic, copy) Progressblock Downloadprogressblock; @end
Benefits: 1, you can see that the Requestdatamodel property is the network request to initiate and return the necessary parameters, so the benefits are really too big, do not know that there is no such scenario: Because the request parameters are different to do a lot of methods interface exposed, the last tune up or the same method, And once the method is written more, and finally should call which method is not known.
2, another Requestdatamodel brings another advantage is the high scalability, you have not encountered the network layer need to add to delete a parameter resulting in the call method modification, and then many places to modify the method? With Requestdatamodel only need to add delete parameters on the line, only need to change the method body, the method body and the method name method is completely two work
Network request essay