diff --git a/MJExtension/MJFoundation.m b/MJExtension/MJFoundation.m index 23a7d8cd..9e340929 100644 --- a/MJExtension/MJFoundation.m +++ b/MJExtension/MJFoundation.m @@ -27,7 +27,8 @@ + (NSSet *)foundationClasses [NSArray class], [NSDictionary class], [NSString class], - [NSAttributedString class], nil]; + [NSAttributedString class], + [NSSet class],nil]; } return foundationClasses_; } diff --git a/MJExtension/NSObject+MJKeyValue.m b/MJExtension/NSObject+MJKeyValue.m index 84fe982b..e3c93a6e 100755 --- a/MJExtension/NSObject+MJKeyValue.m +++ b/MJExtension/NSObject+MJKeyValue.m @@ -186,6 +186,15 @@ - (instancetype)mj_setKeyValues:(id)keyValues context:(NSManagedObjectContext *) } // 3.赋值 + + //赋值前先对CoreData进行处理 + if ([context isKindOfClass:[NSManagedObjectContext class]] && + propertyClass == [NSSet class] && + [value isKindOfClass:[NSArray class]]) + { + value = [[NSSet alloc] initWithArray:value]; + } + [property setValue:value forObject:self]; } @catch (NSException *exception) { MJExtensionBuildError([self class], exception.reason); @@ -706,4 +715,4 @@ - (NSString *)JSONString { return [self mj_JSONString]; } -@end \ No newline at end of file +@end