Re: Temporary object created at runtime with Core Data
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 15:19:54 +0200
When you say "store them", it suggests that you want them to be
persistent. Since you said you didn't, how about thinking of this
in a slightly different light?
Say you have an entity called Smart Group. I would use this
*only* for user-defined, persistent smart groups. The actual
*representation* in the outline view or table view, however,
wouldn't be a direct list of those Smart Group instances.
Instead, how about adding a layer of abstraction between your
persistent smart group instances and your displayed "sources" (as
in "source-list", to continue the iTunes analogy)? You can create
an object that's only responsible for displaying "sources" as an
item in a table/outline view. A "source" instance would have, say,
a pre-defined "entire library" mode, a "podcasts only" mode, or a
"custom smart group" mode (with a reference to the smart group in
question). It can also have an "editable" and "movable" flag so you
can specify whether or not that particular "source" can be edited/
moved around in the source list.
At runtime, the initial "source" items are created (for the
"Library", "Podcasts", etc. lists). Then you can perform a fetch
request for all smart group instances and build *editable* "source"
objects for each one. Use the data source or bindings approach to
display these "source" items instead of directly displaying "Smart
Group" instances in your table/outline view. Of course the "custom
order" or "sort index" would need to be stored with the smart group
instances as well (and your custom "source" object would need to be
aware of this) for custom sorting.
Core Data need not be involved in anything except handing you the
custom, persistent smart group instances.
Note that there're probably even better ways of doing this, but
this is one approach.
--
I.S.
On Apr 25, 2006, at 8:15 AM, Eric Morand wrote:
Why do you want them to be stored there?
Because I don't know where to store them elsewhere. Where could I
insert them if not in a managed context ?
I understand your idea and this is what I'm currently using. :o)
But I don't like it. Because myy smart groups have everything needed
to fetch some datas and I consider that a "Podcasts only" source is
nothing more than a smart group. I don't want to have to design
another custom class for that kind of sources because my smart groups
are exactly what I need.
Eric.
_______________________________________________
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