有没有办法将一个NSManagedObject标记为脏? [英] Is there a way to mark a NSManagedObject as dirty?

查看:130
本文介绍了有没有办法将一个NSManagedObject标记为脏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的NSManagedObject子类中,我有一个NSString ivar,分成一个实体的NSSet。我希望能够设置字符串,并在调用期间保存,但是,只有设置字符串不会触发脏标志或需要保存。

+(BOOL)contextShouldIgnoreUnmodeledPropertyChanges 您可以在 NSManagedObject 上实现 $ c>子类并返回 NO 而不是默认值( YES )。



这样会导致 NSManagedObjectContext 被通知变更属性,即使它们没有由数据库中的实际列表示。


In my NSManagedObject subclass I have an NSString ivar that splits up into an NSSet of entities. I'd like to be able to set the string and during a call to save, do the split, however, only setting the string will not trigger a dirty flag or a need to save.

解决方案

You can implement the + (BOOL)contextShouldIgnoreUnmodeledPropertyChanges on you NSManagedObject subclass and return NO rather than the default (YES).

This should then cause the NSManagedObjectContext to be notified of changes properties even if they aren't represented by actual columns in the database.

这篇关于有没有办法将一个NSManagedObject标记为脏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆