Collections can be simple Attributes in Core Data
Collections can be simple Attributes in Core Data
- Subject: Collections can be simple Attributes in Core Data
- From: Jerry Krinock <email@hidden>
- Date: Thu, 25 Sep 2008 18:08:38 -0700
When I first looked at Core Data, I saw that there was no such
attribute type as "Array" or "Set", and concluded that collections
must be modelled as relationships. This would be overkill in many
cases, for example, in a Person type of application if you wanted to
list the names of each Person's pets, but had no interest in the pets
themselves.
So, one way I worked around this was to store the pet names as an
attribute petNamesString of type String, using a delimiter character,
and transforming on the way in and out of the store. But now I find
there is an even more natural way, which is to just leave them as a
set or array, and store in an attribute of type Transformable. The
default transformer en/decodes the collection into/from an NSData, and
everything "just works".
I'm surprised that I've never seen this discussed or documented. Is
this going to get me into any trouble?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden