ios - Inheritance from an Objective-c base view controller from Swift -



ios - Inheritance from an Objective-c base view controller from Swift -

i trying migrate uiviewcontroller objective-c class swift. view controller inheriting baseviewcontroller have mutual functionality want have in controllers. problem having generated myproject-swift.h not able find baseviewcontroller.

is there way implement uiviewcontroller in swift inherits baseviewcontroller (subclass of uiviewcontroller) written in objective-c? there bridging problem?

it can reproduced minimal code:

baseviewcontroller.h

#import <uikit/uikit.h> @interface baseviewcontroller : uiviewcontroller @end

baseviewcontroller.m

import "baseviewcontroller.h" @implementation baseviewcontroller @end

viewcontroller.swift

import uikit class viewcontroller : baseviewcontroller { }

appdelegate.m

#import "appdelegate.h" #import "projectname-swift.h" // replace project name @implementation appdelegate - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { viewcontroller *vc = [[viewcontroller alloc] initwithnibname:@"viewcontroller" bundle:nil]; self.window.rootviewcontroller = vc; [self.window makekeyandvisible]; homecoming yes; }

projectname-bridging-header.h

#import "baseviewcontroller.h"

as pointed out in accepted reply on how can add together forwards class references used in -swift.h header?

interoperability guide (importing swift objective-c):

if utilize own objective-c types in swift code, create sure import objective-c headers types prior importing swift generated header objective-c .m file want access swift code from.

the illustration solved importing baseviewcontroller before importing projectname-swift.h in:

appdelegate.m

#import "appdelegate.h" #import "baseviewcontroller.h" #import "projectname-swift.h" // replace project name // ...

ios objective-c uiviewcontroller swift

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -