How to get the text out of a WKInterfaceLabel

1.4k Views Asked by At

It seems that labels are a bit different on the Apple Watch!

I have the following label created :

@IBOutlet weak var playerNameLabel: WKInterfaceLabel!

Then writing the label is no problem (with the "setText" method)

let someString = "Hello"
playerNameLabel.setText(someString)

But how do I get the text out of such a Label into a String-constant ???

I tried:

let plaerName_firstTrial: String = playerNameLabel.description  // some weird stuff
let plaerName_secondTrial: String = playerNameLabel.text // error
let plaerName_thirdTrial: String = playerNameLabel // error
let plaerName_fourthTrial: String = ?????
2

There are 2 best solutions below

0
On BEST ANSWER

WKInterfacLabel has only setter property and no getter property as defined by Apple.

Check this WKInterfaceLabel class declaration :

Screenshot for issue

4
On

According to https://developer.apple.com/library/ios/documentation/WatchKit/Reference/WKInterfaceLabel_class/

They only seem to allow setting the text, not getting it (programmatically).