FROM : Cathy Shive
DATE : Sat Mar 22 05:18:37 2008
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/
>
>
>
>
DATE : Sat Mar 22 05:18:37 2008
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/
>
>
>
>
| Related mails | Author | Date |
|---|---|---|
| Jonathan Dann | Mar 19, 12:37 | |
| Cathy Shive | Mar 19, 13:19 | |
| Jonathan Dann | Mar 20, 02:19 | |
| Cathy Shive | Mar 20, 08:40 | |
| Jonathan Dann | Mar 20, 12:35 | |
| Cathy Shive | Mar 20, 13:29 | |
| Paul Szego | Mar 20, 23:27 | |
| Jonathan Dann | Mar 21, 21:49 | |
| Cathy Shive | Mar 21, 22:31 | |
| Steve Weller | Mar 22, 04:25 | |
| Steve Weller | Mar 22, 04:31 | |
| Cathy Shive | Mar 22, 05:18 |






Cocoa mail archive

