I'm currently taking several Swift classes online to figure this new syntax out, but I feel like I've run into a wall that I can't really figure out.
My question is: What do I need to do to call custom Objective-C methods inside Swift? Why doesn't Swift recognize where the code is coming from? Why do I get errors like, "UIViewController does not have a member named 'customMethod'"? Is it an import problem?
Now that you know my question, here is why I'm asking and the background
I have an objective-c .m file that calls this method:
- (void)configureMyApp { // overridden by subclasses } Then this one:
- (void)addAppElement:(MyAppElement *)element { [self addAppElement atIndex:[self.elements count]]; } In my Swift app I've set up the bridging header and imported the .h file into said header file
I attempted calling the configureMyApp method through this Swift function:
func configureMyApp() { self.addAppElement... } but it doesn't recognize that function as coming from my imported objective-c file, and neither does myswiftfile.swift recognize addAppElement
The way I would call it in obj-c would be this:
- (void)configureMyApp { [super configureMyApp]; [self addAppElement:.....]; } Is there anything else I need to do to import the obj-c code? What could I be missing?