• 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
freeing data when closing window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Core Data Key-value question (From: "Bryan Zarnett" <email@hidden>)

  • Prev by Date: NSSearchField (configuring cancel action)
  • Next by Date: avoiding to open window multiple times
  • Previous by thread: Core Data Key-value question
  • Next by thread: avoiding to open window multiple times
  • Index(es):
    • Date
    • Thread