0
votes

I would need to add some contents inside a NSBox, an Image and some text. To do that I use the methods of NSBox class and call them on the object.

I created an IBOutlet:

@IBOutlet weak var theBox: NSBox!

and I also have a button, once I click it, the box will be filled with text (NSTextField):

@IBAction func filler(sender: AnyObject)
{
    var label: NSTextField! = NSTextField()   //Initialized a label to put it in the box
    label.stringValue = "My text hey hey hey!"

    theBox.setContentView(label)       //I GET AN ERROR MESSAGE HERE
}

to add the content I used .setContentViewbut this method is not callable on the object theBoxand I don't know why I am wrong. Look at the documentation. The method exists and it is callable on the NSBox objects.

I'm new with swift and OSX development. Any Idea?

1

1 Answers

1
votes

In Swift, you don't call the set methods for properties, you just assign to them directly:

theBox.contentView = label