1

The title sums it up. I've tried disconnecting/reconnecting all the IBOutlets. Here's the code on my InterfaceController where I set up the WKInterfaceTable:

func setupLoadingTable () {
    self.myTable.setNumberOfRows(1, withRowType:"universalRowID")

    for (var i = 0; i<self.myTable.numberOfRows; i++){
        var row = self.myTable.rowControllerAtIndex(i) as! UniversalRowView
        row.mainTitle.setText("Hello world") //THIS THROWS AN ERROR
    }
}

Here's the code for my UniversalRowView which is my custom row class:

import WatchKit

class UniversalRowView: NSObject {

    @IBOutlet weak var mainTitle: WKInterfaceLabel!
    @IBOutlet weak var subTitle: WKInterfaceLabel!

}

The IBOutlets for the Table is properly connected. The row on Storyboard is set to type UniversalRowView and outlets for both labels are properly connected.

The line:

row.mainTitle.setText("Hello world")

throws the following error: "fatal error: unexpectedly found nil while unwrapping an Optional value"

Also, when I comment that code out, I don't see the stock WKInterfaceLabels on the simulator as they appear on the Storyboard. I feel like this is an error as well but I don't know what to make of it.

Edit: Calling setupLoadingTable() in willActivate()

JustAnotherCoder
  • 2,565
  • 17
  • 38

2 Answers2

6

I figured it out! It seems like there is an attribute in the view of both WKInterfaceTable and WKInterfaceLabel called "38mm Installed". The problem was, I was running the simulator on 42mm but I only had 38mm checked.

Once I checked both attributes, everything worked as planned!

Here's a screenshot of what I'm referring to:

enter image description here

JustAnotherCoder
  • 2,565
  • 17
  • 38
3

I had the same problem and for me it was because I named IBOutlet for my WKInterfaceLabel title which is as it turns out also a name of a method in NSObject.

borisgolovnev
  • 1,780
  • 16
  • 20
  • I encounter the same. However, I don't understand why "title" as a property is not proper when there is a title method? As far as I know, the title method is `func title(for: ABPerson!, identifier: String!)`, which can't be confused with "title" property. – Owen Zhao Jul 28 '18 at 01:03