Simple text editor code from ADC not working !

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

  1. Monaj macrumors regular

    Joined:
    May 24, 2009
    #1
    Hi all,

    I am trying to work on NSDocument, so I tried a simple code provided from this link- http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/TextEditor.html#//apple_ref/doc/uid/20001798

    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- http://www.mediafire.com/?2dgjwmrzt5q

    Thanks,

    Monaj
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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

    Joined:
    May 24, 2009
    #3
    Thanx.. :)
     

Share This Page