[ad_1]
I’m attempting to cross information again from Swift VC2 to ObjC VC1 utilizing delegates whereas dimiss, under is my code.
VC2 (swift):
//protocol used for sending information again
@objc protocol DataEnteredDelegate: AnyObject {
func userDidEnterInformation(data: String)
}
class VC2: UIViewController {
weak var delegate: DataEnteredDelegate? = nil
**//Return to VC1**
@IBAction func doneBtn(_ sender: Any){
session.cease();
delegate!.userDidEnterInformation(data: "sending date from Swift VC2")
self.dismiss(animated: true, completion: nil)
}
VC1.m (objc) file :
#import "ProjectName-Swift.h"
@interface VC1 () <>
@finish
@implementation VC1
**//Navigate to VC2**
- void goToVC2{
VC2 *vc2 = [[UIStoryboard storyboardWithName: @"Main" bundle:nil]
instantiateViewControllerWithIdentifier:@"VC2ID"];
[self presentViewController: vc2 animated: YES completion: nil];
}
@finish
VC1.h –
@interface VC1 : UIViewController
@finish
Find out how to assign the delegate in VC1 earlier than transferring to VC2 and easy methods to implement protocol in VC1 (objc) file i.e. DataEnteredDelegate and the func userDidEnterInformation.
I consider I’ve accomplished the swift a part of the duty however on the lookout for Objc implementation.
[ad_2]
