lijinma
lijinma

Reputation: 2942

'NSTextView' does not have a member named 'setString'

I am new to Cocoa,

I want to replace the content of a NSTextView.

I find a function named setString of NSText, and NSTextView inherits NSText.

So why do I get an error:

NSTextView' does not have a member named 'setString

Thank you.

Right now, I have to use NSTextView.insertText to insert some text.

Upvotes: 2

Views: 559

Answers (1)

Kirsteins
Kirsteins

Reputation: 27345

The actual property is string. Objective-C generates getter and setter (if not read only) methods so you can override their behaviour. Swift has method observers for custom behaviour so you don't need custom getters/setters.

Assign to property directly:

let textView = NSTextView()
textView.string = "text"

Upvotes: 2

Related Questions