Simple text editor code from ADC not working !

Discussion in 'Mac Programming' started by Monaj, Feb 10, 2010.

  1. Monaj macrumors regular

    May 24, 2009
    Hi all,

    I am trying to work on NSDocument, so I tried a simple code provided from this link-

    I did some changes to code which was suggested, such as used property and synthesize in place of declaring and defining accessor methods.

    I followed each step written in the reference but could not implement this step:
    5. If it is not already open, double-click MyDocument.xib to open the document window in Interface Builder. From Xcode, drag the MyDocument.h file icon onto the document window of MyDocument.xib. This step informs the MyDocument.xib file that the MyDocument object interface now has an outlet variable named textView.

    When I compiled, it gave me following warnings in subclass of NSDocument:
    » myDocument may not respond to setString

    MyDocument window did not appear and this message in console appeared each time I tried to execute it: -[MyDocument string]: unrecognized selector sent to instance 0x215970

    Can anyone suggest me where I may be wrong ?? I am trying to run it on Snow Leopard... to check the code you can also download it from-


  2. kainjow Moderator emeritus


    Jun 15, 2000
    The original code implemented setString: and string accessor methods. You changed it to a property, and gave the property the name mString, so you should use setMString and mString as the accessor methods, but since you're using a property you should lose the "m" prefix. So basically rename your "mString" to "string" and it should work.
  3. Monaj thread starter macrumors regular

    May 24, 2009
    Thanx.. :)

Share This Page