• 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
dealloc query for NSTableCellView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dealloc query for NSTableCellView


  • Subject: dealloc query for NSTableCellView
  • From: Jonathan Mitchell <email@hidden>
  • Date: Wed, 04 Feb 2015 13:16:54 +0000

In my arc app I dispose of observers in -dealloc.
The pattern I have established seems to work well but one case has me rethinking my approach.
Everything pivots around NSViewController -representedObject;

- (void)setRepresentedObject:(id)object
{
	if (self.representedObject) [self removeObservers];
	[super setRepresentedObject:object];
	if (self.representedObject) [self addObservers];
}

- (void)dealloc
{
	if (self.representedObject) [self removeObservers];
}

In my query case I have subclassed NSTableCellView. The principle is the same, but the signatures now are:

- (void)setObjectValue:(id)object
{
	if (self.objectValue) [self removeObservers];
	[super setObjectValue:object];
	if (self.objectValue) [self addObservers];
}

- (void)dealloc
{
	if (self.objectValue) [self removeObservers];
}

Crucially I find that in this case after my subclass -dealloc the superclass -dealloc calls -setObjectValue : nil which causes observation warnings to be issued (I always try and clear these types of issues because at the very least they mask real problems) as _objectValue will still be non nil and [self removeObservers] gets called again.

Is it normal for superclasses to message during dealloc?
I could be triggering any sequence of non dealloc friendly actions as a result of the call to -setObjectValue:.

Obviously I can use another property to track whether observations have been removed but that is just more glue.

Perhaps I just need to treat NSTableCellView as a special case and get out the belt and braces?

Thanks

Jonathan














_______________________________________________

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: dealloc query for NSTableCellView
      • From: Roland King <email@hidden>
  • Prev by Date: Re: Job postings at Cocoa mailing list
  • Next by Date: Re: dealloc query for NSTableCellView
  • Previous by thread: Re: Rearranging NSOutlineView via drag-and-drop
  • Next by thread: Re: dealloc query for NSTableCellView
  • Index(es):
    • Date
    • Thread