• 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
many-to-many relationships and retain cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

many-to-many relationships and retain cycles


  • Subject: many-to-many relationships and retain cycles
  • From: Todd Ransom <email@hidden>
  • Date: Mon, 02 Jun 2008 12:12:51 -0400

I have an application that allows users to create relationships between certain objects. For instance, there are scene objects and actor objects (like in a movie). The user can add multiple actors to a scene and an actor can participate in multiple scenes. A classic many- to-many relationship. This is implemented using NSMutableArrays in each object. An actor has a scenesForActor mutableArray and a scene has an actorsForScene mutableArray. This all works great except that it creates retain cycles and neither actor nor scene objects are ever released if they have a relationship.

It seems that what I need is a non-retaining array. I googled around a bit and was surprised that I could not find an existing implementation. It looks like I can create one by subclassing NSMutableArray, overriding the primitive methods, and using a CFArray as the backing store with NULL callbacks to avoid any kind of retain or release when objects are added or removed. Still, I thought I would ask around and see if anyone else has done this before I embark on trying to subclass a class cluster.

Has anyone out there created a non-retaining array class or come up with another solution to this problem? Or is there anything in particular I should watch out for when subclassing NSMutableArray?

thanks,
Todd Ransom
Return Self Software
http://returnself.com



_______________________________________________

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: many-to-many relationships and retain cycles
      • From: Ken Thomases <email@hidden>
    • Re: many-to-many relationships and retain cycles
      • From: Jens Alfke <email@hidden>
    • Re: many-to-many relationships and retain cycles
      • From: j o a r <email@hidden>
  • Prev by Date: Get Value from NSArrayController Binding
  • Next by Date: Re: NSPredicate: To be, or not to be
  • Previous by thread: Re: Get Value from NSArrayController Binding
  • Next by thread: Re: many-to-many relationships and retain cycles
  • Index(es):
    • Date
    • Thread