Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add type check when it is class foundation #849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions MJExtension/NSObject+MJKeyValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,16 @@ + (NSMutableArray *)mj_objectArrayWithKeyValuesArray:(id)keyValuesArray context:
MJExtensionAssertError([keyValuesArray isKindOfClass:[NSArray class]], nil, [self class], @"keyValuesArray参数不是一个数组");

// 如果数组里面放的是NSString、NSNumber等数据
if ([MJFoundation isClassFromFoundation:self]) return [NSMutableArray arrayWithArray:keyValuesArray];

// 则直接判断类型是否一致
if ([MJFoundation isClassFromFoundation:self]) {
NSMutableArray *modelArray = [NSMutableArray array];
[keyValuesArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:self]) {
[modelArray addObject:obj];
}
}];
return modelArray;
}

// 2.创建数组
NSMutableArray *modelArray = [NSMutableArray array];
Expand Down