Where Are Window Size and Positions Stored..?

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

  1. macrumors G3

    Kilamite

    Joined:
    Mar 20, 2007
  2. Moderator emeritus

    kainjow

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

    Kilamite

    Joined:
    Mar 20, 2007
    #3
    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.
     
  4. macrumors 603

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

    Kilamite

    Joined:
    Mar 20, 2007
    #5
    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.
     
  6. macrumors 603

    Joined:
    Aug 9, 2009
    #6
    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