watchkitwatchoswatchos-3wkinterfacelabel

how can I display labels on apple watch?


Xcode 8.0

I try to code my very first app for watchOS. I simply want to show a note when pressing the button. Here is what I've got so far:

import WatchKit
import Foundation


class InterfaceController: WKInterfaceController {

@IBOutlet var myLabel: WKInterfaceLabel!


@IBAction func getNote(){


    print("button pushed")

    myLabel.text = "here is your note"

}

I've tried different approaches already, but really stuck with getting the note on the display. The latest error says "Value of type "WKInterfaceLabel" has no member "text""

Any ideas? Many thanks in advance!


Solution

  • You need to use setText instead of text.

    myLabel.setText("here is your note")
    

    Here's the reference