Saving an Image Well File

Discussion in 'Mac Programming' started by alexpullos, Jun 28, 2011.

  1. alexpullos macrumors newbie

    Jun 28, 2011

    I'm new to the board -- this is my first post. And I'm also a Cocoa newbie.

    Thanks in advance for your patience :)

    I'm writing an application that includes an image well that holds a background image. The application includes a feature that allows the user to change background images at will. And, since the image well is editable, the user can also drag an image in.

    My question is this: If a user drags an image into the image well, how do I save it so that it can be reused in the future?

    If you're able to help and since I'm so new this, please be as specific as possible in your explanation - I promise to pay it forward as quickly as possible ;)


  2. jiminaus macrumors 65816


    Dec 16, 2010
    The NSUserDefaults class will allow you to persist the chosen background. See User Defaults Programming Topics.

    You can bind the NSImageView's value to the a key in the user's defaults. (XCode 4 instructions, XCode 3 should be similar)
    1. Select the image well.
    2. In the bindings inspector, under Value, tick bind to.
    3. Choose Shared User Defaults Controller from the popup menu
    4. Set the controller key to values
    5. Set the model key path to backgroundImage (or whatever)
    6. Set value transformer to NSKeyedUnarchiveFromData
  3. alexpullos thread starter macrumors newbie

    Jun 28, 2011


    Thank you so much!!



Share This Page