• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data Abstractions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data Abstractions


  • Subject: Re: Core Data Abstractions
  • From: Evan DiBiase <email@hidden>
  • Date: Mon, 30 May 2005 15:39:19 -0400

On May 30, 2005, at 2:02 PM, mmalcolm crawford wrote:

Why are you writing the fetch requests?  Are you doing this instead of simply traversing a relationship?  See:
    <http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html#//apple_ref/doc/uid/TP40001802-242985>

The one of the top-level container entities in my application are "ActionList"s; they have a to-many relationship to "Action" entities. I'm using fetch requests in the situation where, for example, I'd like to see if I need to create a default set of ActionLists (by checking to see if any are already in the store). That seems to be about the only case in which I'd need a fetch request, so perhaps this is less of an issue than I originally though.

How are you creating the new instances of your entities?  The NSEntityDescription method makes it a lot easier:
    NSManagedObject *newEmployee = [NSEntityDescription
        insertNewObjectForEntityForName:@"Project"
        inManagedObjectContext:context];

Quite so. That's the method I'm using, and it seems to work well.

Finally, of course, using Cocoa Bindings will also cut out a lot of code, if that's an option.

Bindings are definitely helping, although I'm struggling to apply my half-baked bindings without Core Data knowledge to form a fully-baked bindings with Core Data representation in my head. I think I'm getting there.

Alternatively, you can remove a lot of repetitive code by creating and using fetch request templates:

    NSError *error = nil;
    NSFetchRequest *fr = [[self managedObjectModel] fetchRequestTemplateForName:@"AllProjects"];
    NSArray *projects = [[self managedObjectContext] executeFetchRequest:fr error:&error];

That's perfect. Much cleaner than the code I have been writing. It seems like templates are the way to go for me here.

Thanks!

Evan

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Core Data Abstractions
      • From: mmalcolm crawford <email@hidden>
References: 
 >Core Data Abstractions (From: Evan DiBiase <email@hidden>)
 >Re: Core Data Abstractions (From: Vincent Coetzee <email@hidden>)
 >Re: Core Data Abstractions (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Core Data and Java - anyone?
  • Next by Date: Spotlight, Content Indexing, and SearchKit integration questions
  • Previous by thread: Re: Core Data Abstractions
  • Next by thread: Re: Core Data Abstractions
  • Index(es):
    • Date
    • Thread