Storing contents of NSTextView

Discussion in 'Mac Programming' started by dbramhall, Aug 5, 2011.

  1. dbramhall macrumors newbie

    Aug 1, 2011
    England, UK
    I am trying to store the contents of an NSTextView so that each time the user runs the application, the NSTextView has the same text they exited with. For example, if the user typed in "Hello!" and then quit the application, I would like it to open up with "Hello!" still in the same place. I believe it is NSUserDefaults but I'm not too such as to how to go about implementing it...

    Thanks in advance!
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Break It Down.

    1. How would you preserve the text from the text-field?

    1a) Get the text from the text field.
    1b) Store it in a named NSUserDefaults string.

    2. How would you restore the text back to the text-field?

    2a) Get the name named NSUserDefaults string.
    2b) Store it into the text field.

    If you're looking for the point where you'd do #2, look at awakFromNib:.

Share This Page