Create a nsdictionary Category:
#import <Foundation/Foundation.h>/**/@interface Nsdictionary (Propertycode)// generate Required Property Code -(void) getpropertycode; @end
#import "nsdictionary+propertycode.h"@implementationnsdictionary (Propertycode)//generate the Required property Code- (void) getpropertycode{nsmutablestring*codes = [nsmutablestringstring]; //the traversal dictionary corresponds to all key one by one[Self enumeratekeysandobjectsusingblock:^ (ID_nonnull Key,ID_nonnull obj, BOOL *_nonnull stop) { //Key: Property nameNSString *Code; if([obj iskindofclass:[nsstringclass]]) {Code= [NSString stringWithFormat:@"@property (nonatomic, strong) NSString *%@", key]; } Else if([obj iskindofclass:nsclassfromstring (@"__nscfboolean")]) {Code= [NSString stringWithFormat:@"@property (nonatomic, assign) BOOL%@;", key]; } Else if([obj Iskindofclass:[nsarrayclass]]) {Code= [NSString stringWithFormat:@"@property (nonatomic, strong) Nsarray *%@", key]; } Else if([obj Iskindofclass:[nsdictionaryclass]]) {Code= [NSString stringWithFormat:@"@property (nonatomic, strong) Nsdictionary *%@", key]; } Else if([obj Iskindofclass:[nsnumberclass]]) {Code= [NSString stringWithFormat:@"@property (nonatomic, assign) Nsinteger *%@", key]; } [Codes AppendFormat:@"\n%@\n", code]; }]; NSLog (@"Data Model properties------\n%@", codes);}@end
When parsing data, quickly view all the properties of the data model that you currently need to create, without writing each one, printing and pasting directly