From 7eb9913fa1ff0811ded1675009e23e69301c205a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=B0=E5=8F=81?= <240778488@qq.com> Date: Wed, 8 Sep 2021 18:27:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93EntityName=E5=92=8CC?= =?UTF-8?q?lassName=E4=B8=8D=E4=B8=80=E8=87=B4=E6=97=B6Crash.=20(#718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复当EntityName和ClassName不一致时Crash. Co-authored-by: ligang Co-authored-by: Frank <472730949@qq.com> --- MJExtension/NSObject+MJKeyValue.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MJExtension/NSObject+MJKeyValue.m b/MJExtension/NSObject+MJKeyValue.m index 002f0ad..c48e003 100755 --- a/MJExtension/NSObject+MJKeyValue.m +++ b/MJExtension/NSObject+MJKeyValue.m @@ -255,7 +255,7 @@ + (instancetype)mj_objectWithKeyValues:(id)keyValues context:(NSManagedObjectCon MJExtensionAssertError([keyValues isKindOfClass:[NSDictionary class]], nil, [self class], @"keyValues参数不是一个字典"); if ([self isSubclassOfClass:[NSManagedObject class]] && context) { - NSString *entityName = [NSStringFromClass(self) componentsSeparatedByString:@"."].lastObject; + NSString *entityName = [(NSManagedObject *)self entity].name; return [[NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:context] mj_setKeyValues:keyValues context:context]; } return [[[self alloc] init] mj_setKeyValues:keyValues];