1

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 = ?????
iKK
  • 6,394
  • 10
  • 58
  • 131

2 Answers2

1

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).

valheru
  • 2,552
  • 3
  • 20
  • 40
1

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

Check this WKInterfaceLabel class declaration :

Screenshot for issue

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177