Re: Correct use of NSViewController
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