Skip to content

Commit 5a635dc

Browse files
committed
Fix YYModel Issue。
See <ibireme/YYModel#281>
1 parent d724d65 commit 5a635dc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

YYKit/Model/NSObject+YYModel.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,29 @@ static void ModelSetValueForProperty(__unsafe_unretained id model,
902902
for (id one in valueArr) {
903903
if ([one isKindOfClass:meta->_genericCls]) {
904904
[objectArr addObject:one];
905+
} else if (meta->_genericCls == [NSString class]) {
906+
if ([one isKindOfClass:[NSNumber class]]) {
907+
[objectArr addObject:((NSNumber *)one).stringValue];
908+
}
909+
} else if (meta->_genericCls == [NSMutableString class]) {
910+
if ([one isKindOfClass:[NSString class]]) {
911+
[objectArr addObject:((NSString *)one).mutableCopy];
912+
} else if ([one isKindOfClass:[NSNumber class]]) {
913+
[objectArr addObject:((NSNumber *)one).stringValue.mutableCopy];
914+
}
915+
} else if (meta->_genericCls == [NSNumber class]) {
916+
[objectArr addObject:YYNSNumberCreateFromID(one)];
917+
} else if (meta->_genericCls == [NSURL class]) {
918+
if ([one isKindOfClass:[NSURL class]]) {
919+
[objectArr addObject:[NSURL URLWithString:one]];
920+
} else if ([one isKindOfClass:[NSString class]]) {
921+
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
922+
NSString *str = [one stringByTrimmingCharactersInSet:set];
923+
if (str.length == 0) {
924+
} else {
925+
[objectArr addObject:[[NSURL alloc] initWithString:str]];
926+
}
927+
}
905928
} else if ([one isKindOfClass:[NSDictionary class]]) {
906929
Class cls = meta->_genericCls;
907930
if (meta->_hasCustomClassFromDictionary) {

0 commit comments

Comments
 (0)