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

Re: Collections can be simple Attributes in Core Data


  • Subject: Re: Collections can be simple Attributes in Core Data
  • From: Negm-Awad Amin <email@hidden>
  • Date: Mon, 29 Sep 2008 09:03:20 +0200


Am Fr,26.09.2008 um 03:08 schrieb Jerry Krinock:

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.
If $user changes the name of one person, the names of the pets shouldn't be changed, too?

This "overkill" simply avoids redundancy to ensure consistency.

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.
This seems to be "overkill". ;-)

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?
Yes, because you get redundant and inconsistent model.

Cheers

Amin Negm-Awad
email@hidden




_______________________________________________

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: "I. Savant" <email@hidden>
References: 
 >Collections can be simple Attributes in Core Data (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: How to count composed characters in NSString?
  • Next by Date: Two questions about cocoa programming...
  • Previous by thread: Collections can be simple Attributes in Core Data
  • Next by thread: Re: Collections can be simple Attributes in Core Data
  • Index(es):
    • Date
    • Thread