How can i get the text of label in Swift or Objective-C in WatchKit?
The class is not UILabel but it is WKInterfaceLabel.
I have also tried to search in class library of apple but there is only three methods are available.
Apple has declared WKInterfaceLabel
class with only setter property and no getter property.
This screenshot shows class declaration of WKInterfaceLabel
present in WatchKit framework.
By reading reference it is not possible you have to maintain track which you set in label
looks like apple is very strict about this class you can not create a subclass or direct instance of this.
They only talk about how to set the text not about getting text
Non of it's supper class have method to get text
If its posible You can create extension of WKInterfaceLabel and get text
but no idea if apple approve it or not.
My Conclusion is
Its not possible directly by any way to get text
you can do some trick but make sure that its acceptable by apple.
Just have a @property (nonatomic) NSString *currentText;
That everytime you update or set your WKInterfaceLabel
you also set or update.
It's not the best solution, but it works for now, while Apple doesn't have any official way to get it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With