In Storyboard there is a UIViewController which is controlled by a UINavigationController , its Identifier("vcDen") .
It is in Objective C, it has a method that accepts NSString -(void)setText:(NSString*)text .

How to push this controller from the controller to the swift and transfer to its method which thread the text NSString ?

This scheme does not work! ! !

 let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("vcDen") as UIViewController [vc setText:"gjhgjgjgjhg"] self.navigationController?.pushViewController(vc, animated: true) 
  • Does it not work at all or is the text not transmitted? - Max Mikheyenko
  • already decided ... below, thanks - Denis Nemchenko

1 answer 1

then when we include the swift file in the C project, we have the ObjCProject-Bridging-Header.h bridge file, so we need to make an ordinary Sishny import #import "meClass_C.h" into it, and then I created the object in a swift like this

@IBAction func btnClick (sender: AnyObject) {

  let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("meClass_C") as! meClass_C 

// this creates an object of class written in C (for everyone)

// let myObjClass: meClass_C = meClass_C ()

// myObjClass.sendText ("Den")

  vc.sendText("привет")// у этого Си класса есть метод sendText, который принимает текст и передает далее там self.navigationController?.pushViewController(vc, animated: true) }