iOS-JsonModel通用模型

/**
 Json 通用模型
 */
- (instancetype)initWithDict:(NSDictionary *)dict
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}


+(instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc]initWithDict:dict];

}
+(NSArray *)modelsWithArray:(NSArray *)array
{
    NSMutableArray * arrayM = [NSMutableArray array];

    for (NSDictionary *dict in array) {
        [arrayM addObject:[self modelWithDict:dict]];
    }
    return arrayM;
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"%@",key);

}
- (NSString *)description
{
    return [NSString stringWithFormat:@"sGW:%@ sAuth:%@", self.sGW,self.sAuth];
}

你可能感兴趣的:(iOS-JsonModel通用模型)