• 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: Crash when loading NSViewController view with NSArrayController [solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash when loading NSViewController view with NSArrayController [solved]


  • Subject: Re: Crash when loading NSViewController view with NSArrayController [solved]
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 30 Sep 2012 11:38:06 -0700

On Sun, Sep 30, 2012, at 10:57 AM, Lee Ann Rucker wrote:
> Weird that you didn't get the warning, but we've switched to the pattern
> of
>
> [self addObserver:self forKeyPath:@"ctrl.selectedObjects.someString"...
>
> and that's saved countless headaches. You can remove your own observers
> in dealloc so you never need to worry about when to remove the observer.

Self-observation has always been a code smell to me. I suppose it's a
lot better now that we have -removeObserver:forKeyPath:context:.

In general, it is not a good idea to rely on -dealloc for cleanup of
anything other than object references (that is, sending -release to
strong ivars). Any other resource that requires explicit management
(NSNotificationCenter registration, KVO, file handles, etc.) should not
be managed in -dealloc unless that resource is *explicitly* tied to the
lifetime of the object (a reuse pool, logging).

I'd add and remove my observation in -setCtrl:. Or, since this is a view
controller, perhaps add an explicit teardown method
(-removeViewFromWindow or -windowIsClosing or something) and remove my
observation there.

--Kyle Sluder
_______________________________________________

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

References: 
 >Re: Crash when loading NSViewController view with NSArrayController [solved] (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: Crash when loading NSViewController view with NSArrayController [solved]
  • Next by Date: NSTextField not updated during large process
  • Previous by thread: Re: Crash when loading NSViewController view with NSArrayController [solved]
  • Next by thread: Re: NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
  • Index(es):
    • Date
    • Thread