Damian Mehers' Blog Xamarin from Geneva, Switzerland.

19Nov/147

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.

Filed under: Apple Watch, Swift 7 Comments
2Nov/143

Using the Evernote API from Swift

There is a fine Evernote iOS SDK complete with extensive Objective C examples.  In this blog post I want to share what I did to get it working with Swift.

First I created a new Swift iOS app (called “orgr” below), then I copied the ENSDKResources.bundle and evernote-sdk-ios sources ….

image

… into the new project, and added references to MobileCoreServices and libxml2 per the SDK instructions.

image

In order for the Swift code to see the Evernote Objective C SDK, I enabled the compatibility header and pointed it to a header in the SDK that included all the other headers I needed.

image

I also found (YMMV) that I needed to add a reference to the libxml2 path under Header Search Paths

image

Once I’d done this, I was able to build.  Next it was simply a question of translating the Object C example code to Swift.  This is the minimal example I came up with:

image

You’ll need to replace “token” and “url” parameters with the values you can obtain using the developer token page. This simple example just logs my notebooks.  Next steps are for you …

Filed under: Evernote, iOS 3 Comments