freeing data when closing window
freeing data when closing window
- Subject: freeing data when closing window
- From: "Joris Mans" <email@hidden>
- Date: Sun, 19 Feb 2006 17:13:07 +0100
Hello
Some more noob questions from me ;)
I have multiple nib files in my application, one for each kind of data i
want to edit in an assoc.d window. (e.g. 1 nib file containing instances and
the window to edit an addressbook, etc) as explained in the Apple docs. Now
I want to release the data in memory when the user closes the window (no use
keeping the address book in mem as the user is doing something completely
unrelated in the app). As I found out, there is no way to "unload" or
destroy the global instances contained inside a nib file unfortunately, so I
have to manage this manually. I found a solution, but i was wondering if
there was a more elegant way to do this, because this solution clearly
violates the cleanness of using bindings in my app.
Btw, i am not using NSDocument here.
What i currently do:
in the instance containing all my data, i added an outlet to the NSWindow in
my nib. in awakeFromNib i added:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowClosed:) name:NSWindowWillCloseNotification
object:myWindow];
and in the response to that notification i release the data (i have some
outlets to the arrayControllers used to show the data, on which i set the
content to nil, and i release the local references to the actual arrays
themselves too).
Isnt there a more elegant way, using bindings to respond to the fact that
the user closed the window?
Joris
Joris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden