NSTextView doesn’t initialize when I call readFromData:(NSData *)data ofType:(NSStrin

Discussion in 'Mac Programming' started by NeonKingKong, Feb 18, 2010.

  1. NeonKingKong macrumors member

    NeonKingKong

    Joined:
    Nov 14, 2008
    Location:
    Portland, OR
    #1
    I have a refreshDisplay: method that calls the setString: method of an NSTextView. I can save, and load, but when I load even though my program loads the data, it does not display it on the NSTextView as it should. I did a check and that NSTextView seems to be nil when I load, which is why the setString: method does not do anything to it. I thought this textView would be initialized by interface builder. Any suggestions? Thanks.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Most likely you're trying to access the text view before the nib is loaded, for example in an init method. Try moving it to awakeFromNib.
     
  3. NeonKingKong thread starter macrumors member

    NeonKingKong

    Joined:
    Nov 14, 2008
    Location:
    Portland, OR
    #3
    Thanks, you were right. It's not nil anymore! :)

    Unfortunately, even though my load methods are getting called and temporarily stored and displayed through NSLog, the initializer on my data managing class getting called resets them to new objects, dumping that information I want to keep.

    So I will have to figure out a way to use these objects I'm and have my pointers in my application point to those instead of creating new ones in the init method.


    Actually I called my refreshDisplay method in the awakeFromNib method, and now it says that interfaceBuilder-instantiated object is nil. ?


    Ok this is strange... the init method of the object I archived, and am now loading, is being called when I load the saved file. It shouldn't be called, because I want to unarchived the frozen one. Why is it doing this?
     

Share This Page