Document-based application with multiple fields

Discussion in 'Mac Programming' started by Visceral, Sep 6, 2011.

  1. Visceral macrumors newbie

    Jul 10, 2011

    I created a basic document-based application with a NSTextView in it's UI and am able to get it working properly. The value in the text view gets converted to an NSAttributedString instance variable of the NSDocument subclass and this NSAttributedString is then converted to NSData and returned in the dataOfType:error: method which is called every time the application is closed.

    Now, if I add another NSTextField to the UI and want it also to work, how to do it? dataOfType:error: can return just one NSData after all and in my understanding that is the method which makes the data persist.
  2. Sydde macrumors 68020


    Aug 17, 2009
    You might want to learn how to use NSKeyedArchiver (and its NSKeyedUnarchiver counterpart).
  3. Visceral thread starter macrumors newbie

    Jul 10, 2011
    Glad that you pointed it out. I was starting to think if that is where I need to head next.

Share This Page