Smart Containers
Stefan Urbanek
stefan at agentfarms.net
Tue Feb 6 15:34:30 PST 2007
On 6.2.2007, at 11:27, Christiaan Hofman wrote:
<snip>
>
> And did you consider that NSPersistentDocument creates a store by
> default (though perhaps that doesn't happen now)? I don't see why
> you need the unsavedDocumentStore. Usually new objects belong to a
> document, so the persistent store for that document is present to
> put them in. I can imagine that you're doing something wrong with
> the migration, I don't know too much about that myself (never used
> it, because I never needed it).
>
> What I do, and it works perfect, is create the inMemoryStore in the
> -init of my persistent document.
>
> inMemoryStore = [[coordinator
> addPersistentStoreWithType:NSInMemoryStoreType
> configuration:@"InMemoryConfiguration" URL:nil
> options:nil error:nil] retain];
>
> I use a separate configuration for non-perstistent entities like
> Library groups, so I don't have to explicitly assign them. Whether
> you can do that depends on your model. My -
> configurePersistentStoreCoordinatorForURL:... basically does this:
>
> [coordinator addPersistentStoreWithType:storeType
> configuration:@"PersistentConfiguration" URL:url options:nil
> error:&outError];
>
> The InMemoryConfiguration and PersistentConfiguration are mutually
> exclusive configurations. If you explicitly assign objects to a
> particular store, as in CoreRecipies, you don't need
> configurePersistentStoreCoordinatorForURL:... at all, as the
> default implementation will do. I don't need anything else.
>
> Christiaan
>
Thanks, this works like a charm :) and is much cleaner. I was not
thinking about using configurations.
Only thing I needed to change was to add another (sub)entity for
representing built-in smart folders, as they are only kind of smart
folders that are in memory (others can be in the document store).
Regards,
Stefan
<rest snipped>
Stefan Urbanek
--
http://stefan.agentfarms.net
First they ignore you, then they laugh at you, then they fight you,
then you win.
- Mahatma Gandhi
More information about the MacOSX-dev
mailing list