Binding window location or position to user defaults

This just doesn’t look right. I am new to the user defaults system and untill now I’been using glue code and my own preference file format to save the position of a window when it’s closed so the next time a user runs the app and opens that window it appears in the same place he last closed it. I’m just now looking at how to do that with bindings and when I select a window in IB and open the bindings pane of the Inspector window to see what attributes of a window can be bound I see content hight and content width but nothing about location or position. Seems really odd that they would leave that out.

So my question is, Is that right? A window’s position can not be saved with bindings or am I missing something?

Hi,

in Interface Builder > NS Window Inspector > Attributes just write the name of the window also into the text field “Auto Save Name”

They didn’t “leave anything out”, you’re just trying to make it more complicated than it really is. All you need to do is give your window an ‘auto save name’. In the attributes pane in IB, simply type in a key to use for your window in the “Auto Save Name” field. That’s it. Your application object and the window will handle everything else for you. I would recommend using something unique and descriptive as your autosave name, i.e. “MYAPPMainWindow”.

The only time you might want to roll your own frame saving method is in the rare circumstances where you’re not using your own defaults… such as when creating plugins or bundles. Then you’d need to grab the frame and save its components as an array (list) and save that manually to some file.

Sweet. That just got rid of a bunch more glue code. I’m probably over complicating the Pop up buttons thing too. I’ll have to have another look at that. Actually that’s pretty much th elast of the glue code to be eliminated. :smiley:

Thanks again guys.