-2

I have a project with a lot of objective-c code. Now I would like to access that code in my swift files. But for some reason I can't access the objective-c methods even though I can initiate an object of that class.

I have a bridge-file with all the .h files added called projectName-Bridge-Header.h

#import "NumberVerificationViewController.h"

And it's path is added in the build-settings (a side question: I can initiate an object from a class even though the bridge path isn't added to the build-settings. Why is that?):

enter image description here

I can initialize an object from the class, but I can't access the method:

var num = NumberVerificationViewController()
num.numberVerificationCallCompleted

The last line gives error that method does not exist.

I'm new to objective-c so it might be something really simple. Still, it's beyond me.

Whipper Snapper
  • 185
  • 2
  • 11

1 Answers1

1

At first glance, it looks like you might be missing the declaration in the .h file to make the method public.

NumberVerificationViewController.h
-(void)numberVerificationCallCompleted:(NSNumber*)responseNumber;

NumberVerificationViewController.m
-(void)numberVerificationCallCompleted:(NSNumber*)responseNumber {
    ...
}
valosip
  • 3,167
  • 1
  • 14
  • 26
  • yes, of course! Thanks, completely forgot about checking that. I blame being new to objective-c lol. Thanks again for taking the time! :) – Whipper Snapper Sep 30 '19 at 06:53
  • As for the side question: any idea why I don't need to add bridge location to build settings. It works fine without doing it, but every tutorial I come across say I have to add it. – Whipper Snapper Sep 30 '19 at 06:58