• 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
Collections can be simple Attributes in Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Collections can be simple Attributes in Core Data
      • From: Jerry Krinock <email@hidden>
    • Re: Collections can be simple Attributes in Core Data
      • From: Negm-Awad Amin <email@hidden>
  • Prev by Date: Re: popup button wierdness
  • Next by Date: Re: Bindings Question
  • Previous by thread: Re: Bindings Question
  • Next by thread: Re: Collections can be simple Attributes in Core Data
  • Index(es):
    • Date
    • Thread