Convenient way to ignore/optional *multiple* variable
willard1218 opened this issue · comments
Willard, Lin commented
I have scalar types need to ignore, like this :
@interface PeopleModel : JSONModel
@property (nonatomic, strong) NSString *name;
@property (nonatomic) NSUInteger no;
@property (nonatomic) NSUInteger age;
@end
@implementation PeopleModel
+ (BOOL)propertyIsIgnored:(NSString *)propertyName {
if ([propertyName isEqualToString:@"no"])
return YES;
if ([propertyName isEqualToString:@"age"])
return YES;
return NO;
}
@end
If I have a lot of scalar types to ignore, this method become large,
So I write a convenient method to ignore/optional multiple variable.
willard1218@e84828e
Now, I can ignore scalar types like this :
@interface PeopleModel : JSONModel
@property (nonatomic, strong) NSString *name;
@property (nonatomic) NSUInteger no;
@property (nonatomic) NSUInteger age;
@end
@implementation PeopleModel
+ (NSArray <NSString *>*)ignoredProperties {
return @[@"no", @"age"];
}
@end
James Billingham commented
Why not just do this?
@implementation PeopleModel
+ (BOOL)propertyIsIgnored:(NSString *)propertyName {
return [@[@"no", @"age"] containsObject:propertyName];
}
@end
Willard, Lin commented
I see, you are right.