Where Are Window Size and Positions Stored..?

Discussion in 'Mac Programming' started by kolax, Feb 21, 2010.

  1. kolax macrumors G3

    Mar 20, 2007
  2. kainjow Moderator emeritus


    Jun 15, 2000
    NSUserDefaults stores them, so they go in ~/Library/Preferences/com.yourcompany.yourproduct.plist
  3. kolax thread starter macrumors G3

    Mar 20, 2007
    Thanks for reply. Checked out the plist file for Safari.

    <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.


    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.
  4. chown33 macrumors 604

    Aug 9, 2009
    Does Safari preserve the actual position of its Preferences window?
  5. kolax thread starter macrumors G3

    Mar 20, 2007

    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.
  6. chown33 macrumors 604

    Aug 9, 2009
    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.

Share This Page