Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
NSUserDefaults stores them, so they go in ~/Library/Preferences/com.yourcompany.yourproduct.plist
 

kolax

macrumors G3
Original poster
Mar 20, 2007
9,181
115
Thanks for reply. Checked out the plist file for Safari.

Code:
<key>NSPreferencesContentSize</key>
<string>{508, 240}</string>

I assume that is the window size for Safari (obviously not pixels..)? Can't find anything that would suggest the actual position of the window though.

EDIT:

That aside, if I were have a script to swap the .plist files (say for when I change the resolution), it wouldn't exactly be the best way (but only way..?) since any changes to an application would only apply to one set of plists.
 

kolax

macrumors G3
Original poster
Mar 20, 2007
9,181
115
Does Safari preserve the actual position of its Preferences window?

Haha.

As long as I know it is in the .plist file that's fine.

Right, so when I change resolutions, a script that swaps the .plist files for that resolution would be cool.. bit annoying it means each resolution's apps will have different preferences.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
Haha.

As long as I know it is in the .plist file that's fine.

Right, so when I change resolutions, a script that swaps the .plist files for that resolution would be cool.. bit annoying it means each resolution's apps will have different preferences.

What you should do is read Apple's docs on how window positions and sizes are stored in the user-defaults plist. There is a simple way of saving this data, that works for most apps. But most apps aren't obsessed about resolution changes, a point which you've brought up twice now without explaining exactly what you're trying to do, what your app does, or why you care so much about resolution changes.

There are any number of ways to store your specific data in the user-defaults plist. These can be tailored to specific needs, but you have to read the reference docs to see how things work.

Switching plists with a script is bludgeoning the problem into submission with a very blunt weapon. You might get it to work, but it will hardly be a good use of the API.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.