Note that there are some explanatory texts on larger screens.

plurals
  1. POExtending Core Data generated NSManagedObject classes
    primarykey
    data
    text
    <p>I've been dealing with Core Data for the first time and I wanted to know what the best practices are for extending the classes that Xcode generates for my NSManagedObject entities.</p> <p>I saw <a href="https://github.com/rentzsch/mogenerator#readme" rel="nofollow">mogenerator</a> and I've been also using a similar approach to that as suggested in <a href="http://www.cimgf.com/2011/03/13/super-happy-easy-fetching-in-core-data/" rel="nofollow">SUPER HAPPY EASY FETCHING IN CORE DATA</a>. So I had three kinds of classes:</p> <ul> <li>The EasyFetching category (only one class);</li> <li>A generated NSManagedObject subclass (i.e.: _Entity);</li> <li>A custom subclass with some custom methods like finding all the inactive objects, clearing the cache for an object, etc. (i.e.: Entity).</li> </ul> <p>This approach let me do some custom code while I could refactor my Core Data entity and generate it as many times as I needed. But I've also run into some problems like not being able to declare object level methods for my entities (because the NSManagedObjectContext only knew my _Entity classes).</p> <p>Now I'm using categories to extend my entities functionalities. And this works a lot better because I can have custom object level methods. I now have three kinds of classes:</p> <ul> <li>The EasyFetching category (as it has a lot of methods that all my custom code uses);</li> <li>A generated NSManagedObject subclass (i.e.: Entity);</li> <li>A custom category for my NSManagedObject entity (i.e.: Entity+Custom.h).</li> </ul> <p>My question is: what would you recommend?</p> <p>Thanks in advance for your answers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload