I would like create an abstract base class for NSManagedObject which will use by all the entities of my project.

But, when I click on File > New > File NSManagedObject subclass, I can't create one if I don't link it white an entity from my Core Data model.

I would like to know how create an abstract base class for NSManagedObject

有帮助吗?

解决方案

Don't create a base class, instead, define an @protocol and have each of your managed object subclasses conform to that protocol. By doing this the compiler will verify that they have an implementation of all of the required methods from the protocol.

其他提示

Paul Goracke went into this in depth in a talk a couple of months ago. His blog post is at http://corporationunknown.com/blog/2014/02/16/core-data-potpourri/. Slides are at http://xcoders.s3.amazonaws.com/2014-02-13%20Core%20Data%20Potpourri.pdf, and a video of the talk is at http://vimeo.com/89370886.

I'm a long-time MOGenerator user and fan. Paul's approach to NSMO base class, though, provides almost all of the features that draw me to MOGenerator.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top