NSTextView Set and Get Value?

Hello all,

I have been looking through the documentation and found a command to add text to an NSTextView, but no mention of getting the content of the text view. Can this be done?

I have tried stringValue() and |text|(), both of which don’t work.

Thanks,

Layne

Operating System: Mac OS X (10.7)

Nevermind. :smiley:

After a lot of searching, I found that using

string() instead of stringValue()

and

setString() instead of setStringValue()

works.

I’m sure there’s logic and reasoning behind it, but I found it confusing and irritating at first that one type of field would use string() and another type of field would use stringValue(). I still have trouble remembering which is which if I’ve been away from dealing with fields for a while.

For some reason, NSTextView works directly with NSText, which uses string and setString, so that’s how I found it.

But its still strange that NSTextFields don’t use NSText commands…

NSTextView is a subclass of NSText thats the reason. Knowing how Objective-C’s parenting chain works you should know that when the instance method is not found it will be send to the super class. It’s the same as that the NSOutlineView inherits methods from NSTableView because it’s a subclass of that.

It is interesting though that an NSTextField is not a subclass too.

It doesn’t use the same level of formatting.

True…