• 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: Temporary object created at runtime with Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Temporary object created at runtime with Core Data


  • Subject: Re: Temporary object created at runtime with Core Data
  • From: Eric Morand <email@hidden>
  • Date: Tue, 25 Apr 2006 16:06:33 +0200



If all you're worried about is whether or not you should have a single instance of an entity in your context, don't. You can either abstract like I suggested before (which you don't like), or go ahead and create/store the 'fixed' smart groups when your document is created.


I successfully use this approach in several projects. Consider (in your persistent document):

- (id)librarySmartGroup
{
    // Check private ivar to see if it's set (like _librarySmartGroup)
    // If not ...
      // Try to fetch "the" library smart group
      // If none available, create and insert one
      // Assign the fetched or inserted one to the ivar for caching
    // Return the ivar
}

If there's ever the possibility of another smart group being manually inserted (such as a user editing an XML file), you will need to think about a "verification" process to make sure there's still only ever one per document.

I may be totally missing the point of your question, however, so forgive me if this doesn't apply. I *do* think, however, in the case of an iTunes-like "smart group" scenario, my original suggestion (adding a layer of abstraction) is still the better way to go because you don't have to store things that are common to *all* of your documents. I mean, depending on the selection, you can still easily get to that group's predicate, whether fixed or customizable ...




I perfectly agree with this point : since these smart groups are common to all my documents, they should not be stored in the database. But I hate to have to do the same work twice and if I use a layer of abstraction, I have to (I'll have two sorts - classes - of smart goups : one only used for the "common" groups, and the other for the custom groups which are stored in the database).

That's why I was thinking about using the already perfectly working smart groups NSManagedObject subclass, create them at run-time and store them in a "in memory store".
_______________________________________________
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: Temporary object created at runtime with Core Data
      • From: William Bumgarner <email@hidden>
    • Re: Temporary object created at runtime with Core Data
      • From: "I. Savant" <email@hidden>
References: 
 >Temporary object created at runtime with Core Data (From: Eric Morand <email@hidden>)
 >Re: Temporary object created at runtime with Core Data (From: Ondra Cada <email@hidden>)
 >Re: Temporary object created at runtime with Core Data (From: Eric Morand <email@hidden>)
 >Re: Temporary object created at runtime with Core Data (From: "I. Savant" <email@hidden>)
 >Re: Temporary object created at runtime with Core Data (From: Eric Morand <email@hidden>)
 >Re: Temporary object created at runtime with Core Data (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: Superimpose a NSTextField over NSImageView?
  • Next by Date: Re: Which exception handling system should I use?
  • Previous by thread: Re: Temporary object created at runtime with Core Data
  • Next by thread: Re: Temporary object created at runtime with Core Data
  • Index(es):
    • Date
    • Thread