开发者

Must NSManagedObject subclasses by passed to the controller or should these objects remain only in the model

开发者 https://www.devze.com 2023-04-08 13:07 出处:网络
The reason I ask is because I have separate domain objects which I map from the NSManagedObject subclasses so as to kee开发者_开发问答p my data access logic separate.

The reason I ask is because I have separate domain objects which I map from the NSManagedObject subclasses so as to kee开发者_开发问答p my data access logic separate.

But I think its going to be a problem for updating.


I wouldn't say that NSManagedObject subclasses must be passed to a controller object: In theory you could do what you're describing, and build a "front end" layer that sits between your Core Data model and your controllers – you're creating a lot more work, of course, and it might be just as easy to throw out your old model and start over, if and when you ever do decide to stop using Core Data.

You may also have to put more effort into keeping your model objects separate from your controller objects, what with a middle layer that could easily become a hodgepodge of both. It sounds like you've already gone down this road, though, so the question is probably more about the best use of your time and resources, and whether it's more cost-effective to phase out the middle layer or maintain it.


If you mean should you pass MySubclass vs NSManagedObject; it does not matter. The instance is what it is, your subclass. You can call it anything in between id and MySubclass.

So you can set up your controller to accept just an id or NSManagedObject you can pass it your subclass without an issue. If you want more exposed control to the subclass then you can pass around the subclass.

If that does not answer your question then I suggest you expound upon your question with an example.

0

精彩评论

暂无评论...
验证码 换一张
取 消