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

对coreData嵌套解析做处理 #487

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion MJExtension/MJFoundation.m
Expand Up @@ -27,7 +27,8 @@ + (NSSet *)foundationClasses
[NSArray class],
[NSDictionary class],
[NSString class],
[NSAttributedString class], nil];
[NSAttributedString class],
[NSSet class],nil];
}
return foundationClasses_;
}
Expand Down
11 changes: 10 additions & 1 deletion MJExtension/NSObject+MJKeyValue.m
Expand Up @@ -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);
Expand Down Expand Up @@ -706,4 +715,4 @@ - (NSString *)JSONString
{
return [self mj_JSONString];
}
@end
@end