• 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: Core Data Many2Many Relationships
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data Many2Many Relationships


  • Subject: Re: Core Data Many2Many Relationships
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 04 Aug 2005 06:08:01 -0400

on 2005-08-04 4:50 AM, Chris Blunt at email@hidden wrote:

> I have a core data model set up for domains and extras, where one
> domain can have several extras and one extra can belong to many
> domains. I have set up an object in the middle called DomainExtra as
> a link to connect the two:

In Core Data, you don't need the middle object. Simply set up a to-many
relationship in domain for extras, and another in extra for domains, and
mark the relationships as the inverse of one another.

One way to populate the extras relationship in a domain object
programmatically is to make domain a subclass of NSManagedObject and
implement the -add<Keys>Object and related Core Data accessor methods. In
your case, you would name these -addExtrasObject: to link a single extra
object into a domain object, and -addExtras: to add a set of extra objects
to a domain object. Since the relationships are inverse (i.e.,
many-to-many), this would automatically link the domain object to the extra
object (or each of the extras objects) at the same time.

To unlink an extra object from a domain object, you could implement
-remove<Keys>Object: and -remove<Keys>:.

The Core Data documentation contains example code for implementing these
methods.

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes


 _______________________________________________
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

  • Follow-Ups:
    • Re: Core Data Many2Many Relationships
      • From: mmalcolm crawford <email@hidden>
References: 
 >Core Data Many2Many Relationships (From: Chris Blunt <email@hidden>)

  • Prev by Date: Bordercolor?
  • Next by Date: Holding ALT changes button icon and behaviour - best practice?
  • Previous by thread: Re: Core Data Many2Many Relationships
  • Next by thread: Re: Core Data Many2Many Relationships
  • Index(es):
    • Date
    • Thread