In Swift application I have a
ViewController, which call a new modal.This
modal have as ViewController Objective-C implementation as ViewController_obj_c.This
modal is shown from Swift code and I want to call the callback property (with UIImage paramter), when the Objective-C code is done.Me callback property
"signCompleteCallback" doesn't work. How can I fill a callback property from Swift and call it inside Objective-C ?SwiftViewController.swift:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showModalSegue" {
if let nextVC = segue.destination as? ViewController_obj_c {
nextVC.signCompleteCallback = #selector(self.Test) // filled objective-c selector here
}
}
}
@objc func Test(image: UIImage)
{
debugPrint("Test method was called as callback with image parameter")
}ViewController_obj_c.h:
@interface ViewController_obj_c : UIViewController
@property SEL signCompleteCallback;
- (IBAction)Done_Clicked:(id)sender;ViewController_obj_c.m:
- (IBAction)Done_Clicked:(UIButton *)sender
{
UIGraphicsBeginImageContext(_dV.bounds.size);
[_dV.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self signCompleteCallback]; // Here is the point when i want to call me callback and as a parameter i want to send image
}