Runtime reflection attribute list:
Describe the usage of reflection attributes...
There should be no stranger to IOS network requests, but sometimes we need to transmit a lot of data to the server. This is also the time for us to use runtime.
Directly go to the Code, and the kids shoes are estimated to be swearing soon. A reflection attribute, for so long...
-(void)createPostDateWithDic{ NSArray * arr = [self.requestDictionary allKeys]; for (int i = 0; i < arr.count; i ++) { if ([self.requestDictionary objectForKey:[arr objectAtIndex:i]] != nil) { [self.mainRequest setPostValue:[self.requestDictionary objectForKey:[arr objectAtIndex:i]] forKey:[arr objectAtIndex:i]]; } };}-(void)createPostDateWithModel{ unsigned int outCount, i; objc_property_t *properties = class_copyPropertyList([self.requestModel class], &outCount); for (i=0; i<outCount; i++) { objc_property_t property = properties[i]; NSString * key = [[NSString alloc]initWithCString:property_getName(property) encoding:NSUTF8StringEncoding]; id value = [self.requestModel valueForKey:key]; if (value != nil) { [self.mainRequest setPostValue:value forKey:key]; } }}
The above two methods are used in self-encapsulated POST network requests. Based on ASI, the use of these two methods will make the code implementation of your network request very brief and efficient.
Now, I believe that you have learned about the usage of the runtime reflection attribute. If you have any questions, please leave a message. Provide more valuable comments.