Extremely new to Swift and Objective C. My manager has tasked me with reposting an outdated app back onto the app store. It was removed due to some Apple updates and our app didn't meet the new qualifications. But I've been having issues just trying to compile the project. So I by first updating the project by running updates on its old software like XCode. But now I'm stuck at this issue of the AppDelegate Swift functions can't be seen in the objective C code. However, when I right-click and go to definition, it has has no problem finding them. This is one example.
CodePudding user response:
You need to add
@objc
as prefix for variables or functions which you would like to access from Swift file to Objective C or mark class as@objcMembers
if you want to access everything from swift file to Objective cmake sure you have created a bridging header file. Here is helper link
You need to import that bridging header in your Objective C file.
If you have do all three steps as mentioned, you will be able to access that function.
CodePudding user response:
In your code you are accessing instance methods as class methods
Error itself saying that
No known class method for selector 'myBlue'
Follow below steps
@property(nonatomic,strong) IBOutlet AppDelegate *appDelegate; // .h file
self.appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; // .m file. //ViewDidLoad Method
Now you can access method as
[self.appDelegate myBlue]
Else
[delegate myBlue] // as per your code
Finally you need to know difference between Class & Instance Methods
-(void)someInstanceMethod{
//Whatever you want your instance method to do here
}
(void)someClassMethod{
//Whatever you want your class method to do here
}
Hope it helps.