ixany ixany - 1 year ago 406
Swift Question

Display Text using a NSScrollView

I just started learning Swift and created a little OSX-App, in which I want to use a

to display a
. I tried:

@IBOutlet var ScrollViewOutlet : NSScrollView
var attributedString = NSMutableAttributedString(string: myText)

... but sadly, it's not working. it's a bit confusing, because with an
instead, I have no problems. Where is my mistake?

Answer Source

seems that the earlier betas of xcode had some issues with this kind of outlets (as you can see here swiftwtf.tumblr.com/post/88387419568/nstextview), however, since xcode 6 beta 6 its working.

i noticed that you can't change the content of the NSScrollView or NSTextView directly, so i did the following, setting only the string in textStorage

textFieldOutlet.textStorage.mutableString.setString("your string here")

... and it worked fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download