• 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: Cathy Shive <email@hidden>
  • Date: Sat, 22 Mar 2008 05:18:37 +0100

It's so interesting to me to see different people's way of dealing with this. Seems like everyone's design is very similar - they just differ in the implementation details.

I hope Apple will fill in the blanks in the framework eventually. We have all come to the same solution in a certain way, but it would be easier for us to help each other if we were using the same architecture.

Still, pretty interesting :)

Cathy

On Mar 22, 2008, at 4:31 AM, Steve Weller wrote:


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


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>)
 >Re: Correct use of NSViewController (From: Steve Weller <email@hidden>)

  • Prev by Date: Re: Correct use of NSViewController
  • Next by Date: Re: Synchronising across multiple NSUndoManager stacks
  • Previous by thread: Re: Correct use of NSViewController
  • Next by thread: Re: Correct use of NSViewController
  • Index(es):
    • Date
    • Thread