WatchKit Error – unable to instantiate row controller class

Trying to create a simple WatchKit table, I hit the error shown in this blog post title.

You mileage may vary, but the eventual cause was that when I added my custom RowController class I accidentally added it to the wrong module … I added it to the main iOS app (WatchTest) instead of the Watch extension:

image

The first hint of this was when I was trying to reference the RowController when calling rowControllerAtIndex, and my custom row controller class could not be found:

var rootRow = rootTable.rowControllerAtIndex(0) as RootRowController

By this time I’d already set it as the RowController class for my table’s row in the storyboard, and had inadvertently referenced the wrong module:

image

I fixed the compilation error by adding my custom RowController to the Watch extension module, but accidentally added it to both modules:

image

Everything compiled but when I ran the log shows the error from the title: Error – unable to instantiate row controller class

image

I eventually figured out my mistake, and made sure that the row controller only belonged to the extension module:

image

And I made sure the correct module was referenced when defining the RowController in the storyboard:

image

It would be nice if the Watch App’s storyboard only saw classes in the Watch Extension’s module.

7 thoughts on “WatchKit Error – unable to instantiate row controller class

  1. hurrtz

    Hey, just wanted to add that there is another reason for this error to happen. When the class of the row controller is not derived from NSObject then instantiation of the row will also fail.

    In my case I had the problem that my row controller was derived from WKInterfaceTable. Of course that doesn’t make sense, but it was just like that. And with this configuration the error came.

    So: Always check if your classes are derived from the correct superclasses 🙂

    Reply
  2. Scotty

    “And I made sure the correct module was referenced when defining the RowController in the storyboard”

    That saved me! I couldn’t find anything related to this problem on stackoverflow. Thank you.

    Reply
  3. Sebastian

    Thanks a lot for this post. I have copied sow rows from an storyboard of watchOS1 to watchOS2 storyboard and it kept the old module name…

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *