views:

13

answers:

0

Hello,

I'm using CoreData and I have two managed objects: Author and Book. An author can have may books, but a book can only have one author (for the sake of this example).

The class Author extends NSManagedObject and Book extends NSManagedObject also. In my Author class, is it OK to create an extension, so that I can do custom searches within author. For example, would it be OK to write:

  Author* theAuthor = /* found somewhere else */
  NSArray* books = [theAuthor booksWrittenAfter:2009];

where the call to 'booksWrittenAfter:' would do the search in CoreData, returning books written after 2009 for that author?

I have written this in code and it works and compiles, I was just wondering if this was OK to do, or whether all searches in CoreData should be done in another class and the classes Author and Book are kept simpler?

Thank you very much!

Michael