Skip to content

Commit

Permalink
支持多维数组转化,数组字段多维混合结构待支持,准备增加新的配置类方法加以实现
Browse files Browse the repository at this point in the history
  • Loading branch information
Minster committed Jan 22, 2018
1 parent 1230e60 commit 6067e57
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions YYModel/NSObject+YYModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ static void ModelSetValueForProperty(__unsafe_unretained id model,
NSObject *newOne = [cls new];
[newOne yy_modelSetWithDictionary:one];
if (newOne) [objectArr addObject:newOne];
} else if ([one isKindOfClass:[NSArray class]]) {
NSArray *objectArrInner = [NSArray yy_modelArrayWithClass:meta->_genericCls json:one];
[objectArr addObject:objectArrInner];
}
}
((void (*)(id, SEL, id))(void *) objc_msgSend)((id)model, meta->_setter, objectArr);
Expand Down Expand Up @@ -1795,9 +1798,13 @@ + (NSArray *)yy_modelArrayWithClass:(Class)cls array:(NSArray *)arr {
if (!cls || !arr) return nil;
NSMutableArray *result = [NSMutableArray new];
for (NSDictionary *dic in arr) {
if (![dic isKindOfClass:[NSDictionary class]]) continue;
NSObject *obj = [cls yy_modelWithDictionary:dic];
if (obj) [result addObject:obj];
if ([dic isKindOfClass:[NSDictionary class]]) {
NSObject *obj = [cls yy_modelWithDictionary:dic];
if (obj) [result addObject:obj];
} else if ([dic isKindOfClass:[NSArray class]]) {
NSArray *objectArrInner = [NSArray yy_modelArrayWithClass:cls json:dic];
[result addObject:objectArrInner];
}
}
return result;
}
Expand Down

0 comments on commit 6067e57

Please sign in to comment.