MJExtension icon indicating copy to clipboard operation
MJExtension copied to clipboard

对于继承至NSManagedObject的模型,如何在转

Open tospery opened this issue 11 years ago • 2 comments

对于继承至NSManagedObject的模型,如何在把字典集合转换为对象数组的时候,不在Core Data中放入快照? // 如下语句会造成Core Data中存在快照,即使没有save,本次运行中它都会存在。 NSArray *coupons = [LHCoupon objectArrayWithKeyValuesArray:response context:[NSManagedObjectContext MR_defaultContext]];

            // 如下语句转成的coupons,在访问它们的属性时会crash
            NSArray *coupons = [LHCoupon objectArrayWithKeyValuesArray:response context:nil];

tospery avatar Sep 03 '15 00:09 tospery

对这个问题我也想问,一般我们用coredata时候如果不需要将新建对象放入上下文只需在新建方法中把context参数置为nil,但是如果用objectArrayWithKeyValuesArray 不传context的时候是不会调用insertNewObjectForEntityForName 来建继承与NSManagedObject 对象的,setter 和 getter方法都木有动态生成啊,怎么办啊 MJ哥

blackchena avatar Sep 21 '15 08:09 blackchena

    NSManagedObjectContext *context = [UserManage sharedInstance].coreDataStore.context;

Gensun avatar Mar 20 '20 05:03 Gensun