Re: "Library" smart group in Core Data
Re: "Library" smart group in Core Data
- Subject: Re: "Library" smart group in Core Data
- From: Jonathon Mah <email@hidden>
- Date: Mon, 30 Jan 2006 00:08:34 +1030
Hi Ben,
On 2006-01-28, at 09:22, Ben Kazez wrote:
I'm developing a Core Data application with an interface similar to
iTunes, iPhoto, and other applications, in which a Source table
lists a group called "Library" that contains all the items the
application manages.
I am currently doing the same. The solution I used was to make a
LibraryAlbum subentity of Album, overriding the -photos accessor to
return all the objects with entity Photo. You also need to observe
the managed object context and update yourself as the photos change.
(See Core Recipes for how to do this.)
When the document first gets created, I create a single LibraryAlbum,
and store a reference to it in my NSPersistentDocument subclass
(similar to Core Recipes). When I load a document, I fetch all
LibraryAlbum objects (there should only be one) and hang onto the
first one.
This code shows how to make an object on document creation:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
NSPersistentDocumentTutorial/04_Department/chapter_5_section_2.html>
I also looked into using an in-memory store, but it seemed
unnecessary. I vaguely remember Core Recipes using it for importing
from multiple documents, which my app doesn't do. If you do use
multiple stores, you have to specify a store on creation of every
object. And there's no harm in storing a tiny Library object in your
document file. :)
For my source table view, I used a "priority" key like Core Recipes
to keep the Library group at the top.
Hope this helps,
Jonathon Mah
email@hidden
_______________________________________________
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