0

I'm creating an apple watch app but I can't seem to get the simple act of updating the label on a controller to work.

I've tried this in multiple functions but none of them are updating the label from it's default text.

I've added print statements to make sure the functions are being called, and they print to the console as expected. The Label reference is correct as well.

class HomeController: WKInterfaceController {

@IBOutlet weak var walkerTitle: WKInterfaceLabel!

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
    print("didAppear")
    print(User.Player.getTitle())
    walkerTitle.setText(User.Player.getTitle() + " Walker");
}

override func didAppear() {
    super.didAppear()
    print("didAppear")
    print(User.Player.getTitle())
    walkerTitle.setText(User.Player.getTitle() + " Walker");
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()
    print("didDeactivate");
}

}

Screenshot of the app next to the console

I've attached an image of the app next to the console (with irrelevant print statements whited out). Any help would be greatly appreciated :)

How do I get the label to update on the controller?

Edit:

I've added the logs before the app is loaded here:

skipping /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim 2021-03-23 19:52:21.689294+1030 PDC Hatch WatchKit Extension[718:30700] [default] lookupMainFuncAddressInMachHeader:71: Invalid Swift entry point data 2021-03-23 19:52:21.690275+1030 PDC Hatch WatchKit Extension[718:30700] [default] lookupMainFuncAddressInMachHeader:77: Swift entry point addres could not be determined. 2021-03-23 19:52:21.944316+1030 PDC Hatch WatchKit Extension[718:30700] [default] +[SPRemoteInterface controller:setupProperties:viewControllerID:tableIndex:rowIndex:classForType:]:2719: Unknown property in Interface description ('PartnerImage') for controller <PDC_Hatch_WatchKit_Extension.HomeController: 0x600001b255c0> 2021-03-23 19:52:21.945384+1030 PDC Hatch WatchKit Extension[718:30700] [default] +[SPRemoteInterface controller:setupProperties:viewControllerID:tableIndex:rowIndex:classForType:]:2719: Unknown property in Interface description ('DailyGoalPercent') for controller <PDC_Hatch_WatchKit_Extension.HomeController: 0x600001b255c0> 2021-03-23 19:52:21.945625+1030 PDC Hatch WatchKit Extension[718:30700] [default] +[SPRemoteInterface controller:setupProperties:viewControllerID:tableIndex:rowIndex:classForType:]:2719: Unknown property in Interface description ('AllEggs') for controller <PDC_Hatch_WatchKit_Extension.HomeController: 0x600001b255c0>

The unknown properties seem to be outlets I reference but have since deleted. I'm not sure why they are still showing up in the logs.

impo
  • 747
  • 1
  • 11
  • 37
  • 1
    What does that log say: controller:setupProperties... etc? – Shadowrun Mar 23 '21 at 09:08
  • 1
    Does the WKInterfaceLabel have an attributed string set in the storyboard? – Shadowrun Mar 23 '21 at 09:21
  • @Shadowrun I don't know why my brain glossed over those... I have edited them into my question. They mostly seem to be outlets I had referenced in the controller but since deleted – impo Mar 23 '21 at 09:27
  • @Shadowrun I set the text to "XXXXXXX Walker" in the storyboard - I'm not sure if that is the attributed string – impo Mar 23 '21 at 09:27
  • @Shadowrun I thought I deleted the reference outlets but I didn't do it properly. Deleting them via the storyboard has done the trick. Thanks! – impo Mar 23 '21 at 09:33

1 Answers1

0

My problem was that I had reference outlets that I had deleted in code but not in the storyboard.

Once I deleted the reference outlets that were erroring and rerun the app it updated correctly.

impo
  • 747
  • 1
  • 11
  • 37