samedi 25 avril 2015

Import swift class into objective c storyboard


Im trying to integrate implement the project http://ift.tt/YXSBoY into my objective c project.

I have an objc bridging header that Xcode automatically made for me

I translated the ViewController.swift code as such

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Walkthrough" bundle:nil];
BWWalkthroughViewController *walkthrough = [sb instantiateViewControllerWithIdentifier:@"walk"];
BWWalkthroughPageViewController *page_zero = [sb instantiateViewControllerWithIdentifier:@"walk0"];
BWWalkthroughPageViewController *page_one = [sb instantiateViewControllerWithIdentifier:@"walk1"];
BWWalkthroughPageViewController *page_two = [sb instantiateViewControllerWithIdentifier:@"walk2"];
BWWalkthroughPageViewController *page_three = [sb instantiateViewControllerWithIdentifier:@"walk3"];

walkthrough.delegate = self;
[walkthrough addViewController:page_zero];
[walkthrough addViewController:page_one];
[walkthrough addViewController:page_two];
[walkthrough addViewController:page_three];

[self presentViewController:walkthrough animated:YES completion:nil];

and I import the swift classes like so:

import "SkipTheLine-Swift.h"

My bridging header file's name is "SkipTheLine-Bridging-Header.h"

now, when I run the code, I get this

2015-04-25 16:47:46.740 SkipTheLine[1631:215786] Unknown class BWWalkthroughViewController in Interface Builder file. 2015-04-25 16:47:46.754 SkipTheLine[1631:215786] -[UIViewController setDelegate:]: unrecognized selector sent to instance 0x12651cf90 2015-04-25 16:47:46.755 SkipTheLine[1631:215786] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setDelegate:]: unrecognized selector sent to instance 0x12651cf90' * First throw call stack: (0x1838aa530 0x19482c0e4 0x1838b15f4 0x1838ae3ac 0x1837b2c4c 0x10009c494 0x1880eca14 0x1880d5d08 0x1880ec3b0 0x1880ec03c 0x1880e5590 0x1880b8e60 0x18835846c 0x1880b73d0 0x183862d34 0x183861fd8 0x183860088 0x18378d1f4 0x18cbb76fc 0x18811e10c 0x10009e174 0x194eaaa08) libc++abi.dylib: terminating with uncaught exception of type NSException

Any ideas as to how I can use the swift code in interface builder?


Aucun commentaire:

Enregistrer un commentaire