• 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
KVO and object release timing (for a NSCollectionView)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KVO and object release timing (for a NSCollectionView)


  • Subject: KVO and object release timing (for a NSCollectionView)
  • From: vincent habchi <email@hidden>
  • Date: Fri, 22 Jan 2010 16:01:14 +0100

Hi again,

in my project, I have a managed object A, that has a relationship to an other managed object B, itself in relation with a third object C (which happens to be a CALayer, therefore is not part of Core Data): A -> B -> C.

The object A I register in a NSArrayController, whose content is linked to a NSCollectionView. The NSView I use to visually represent the NSArrayController contents includes a slider that observes a parameter of C (more specifically, opacity) through KVO.

So far, so good.

I have a NSButton in C to remove from the array controller the A object it represents. However, each time I click on that button, I first get a warning telling me that I remove an observed object before releasing the observer, and then the program crash, albeit:
- I've set the relation option between A and B to leave B alone when A is deallocated;
- I keep a temporary pointer on A and release C before A is removed from the array controller.

NSArrayController controller;
id A, B, C

(void)removeA:(id)sender {
	id tmp = [A retain];
	[controller removeObject:A];
	[[[A getB] getC] release];
	[[A getB] release];
	[tmp release];
}

It seems the object in the NSCollectionView persists some time after A is removed from the array. Of course, I could twist the action and redirect it somehow to the slider so it would unregister (which would mean somehow subclassing it) and then pass a message the remove message to A. Is there any simpler solution ?

I hope this is not too obscure.

Thanks,
Vincent_______________________________________________

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: KVO and object release timing (for a NSCollectionView)
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: Re: Correct Bindings Practices
  • Next by Date: Re: How to avoid launching the same application multiple times?
  • Previous by thread: Re: iPhone: subclassing UIView for blendmode
  • Next by thread: Re: KVO and object release timing (for a NSCollectionView)
  • Index(es):
    • Date
    • Thread