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 parameter), when the Objective-C code is done.
My 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)
}
}
}
@objc func Test(image: UIImage)
{
debugPrint("Test method was called as callback with image parameter")
}
ViewController_obj_c.h:
@interface ViewController_obj_c : UIViewController <UIPopoverPresentationControllerDelegate>
@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
}