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

alexpullos

macrumors newbie
Original poster
Jun 28, 2011
2
0
Hello,

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 ;)

Thanks!

Alex
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.