• 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: Correct use of NSViewController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct use of NSViewController


  • Subject: Re: Correct use of NSViewController
  • From: Steve Weller <email@hidden>
  • Date: Fri, 21 Mar 2008 20:31:05 -0700


On Mar 21, 2008, at 2:31 PM, Cathy Shive wrote:
1, window is about to close (wish there was a more reliable place to do this, but it has to be before dealloc):

windowController:

- (void)windowWillClose
{
[mViewController removeObservations]; // this causes the method to be called all the way down the view controller tree
}


2.  view controller removes it's observations

viewController:

- (void)removeObservations
{
	[wArrayController removeObserver:self forKeyPath:@"selectedObjects"];
	[super removeObservations];
}

3. The document closes and the window controller is released and dealloced:

window controller:
- (void)dealloc
{
	[mViewController release];
	[super dealloc];
}

3.  The first view controller is released and dealloced:

viewController:
- (void)dealloc
{
	[mSubcontrollers release];
	[super dealloc];
}

I do a very similar thing, but name things differently. Instead of telling the lower objects what to do (remove observations) I tell them what is happening at the high level so they can do their own thing based on that (window is closing.. so I'll remove my observers). This lets me keep everything out of dealloc except for memory management. In that way if I switch to GC it will still work.



-- Blog: http://www.bagelturf.com/ Photos: http://bagelturf.smugmug.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: Correct use of NSViewController
      • From: Cathy Shive <email@hidden>
References: 
 >Correct use of NSViewController (From: Jonathan Dann <email@hidden>)
 >Re: Correct use of NSViewController (From: Cathy Shive <email@hidden>)
 >Re: Correct use of NSViewController (From: Jonathan Dann <email@hidden>)
 >Re: Correct use of NSViewController (From: Cathy Shive <email@hidden>)
 >Re: Correct use of NSViewController (From: Jonathan Dann <email@hidden>)
 >Re: Correct use of NSViewController (From: Cathy Shive <email@hidden>)
 >Re: Correct use of NSViewController (From: Jonathan Dann <email@hidden>)
 >Re: Correct use of NSViewController (From: Cathy Shive <email@hidden>)

  • Prev by Date: Re: Correct use of NSViewController
  • Next by Date: Re: Correct use of NSViewController
  • Previous by thread: Re: Correct use of NSViewController
  • Next by thread: Re: Correct use of NSViewController
  • Index(es):
    • Date
    • Thread