Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要帮助将这段代码从Swift转换为Objective-C吗_Objective C_Swift - Fatal编程技术网

需要帮助将这段代码从Swift转换为Objective-C吗

需要帮助将这段代码从Swift转换为Objective-C吗,objective-c,swift,Objective C,Swift,我有一个Objective-C应用程序,我需要从代码中加载另一个VC类。我已经设法在另一个Swift应用程序中实现了这一点 let storyboard = UIStoryboard(name: "Main", bundle: nil) let controller = storyboard.instantiateViewController(withIdentifier: "OverrideClass") self.present(controller, animated: true, com

我有一个Objective-C应用程序,我需要从代码中加载另一个VC类。我已经设法在另一个Swift应用程序中实现了这一点

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "OverrideClass")
self.present(controller, animated: true, completion: nil)

我需要帮助为ObjC创建一个相同的函数。它基本上是用代码中提到的脚本标识符加载VC类。

代码非常相似,只是语法不同

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:NULL];
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"OverrideClass"];
[self presentViewController:controller animated:YES completion:NULL];

以下是您提供的代码,它们是用Objective-C重新编写的:

UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:NULL];
UIViewController * controller = [storyboard instantiateViewControllerWithIdentifier:@"OverrideClass"];
[self presentViewController:controller animated:YES completion:NULL];

任何Objective-C教程都将向您展示其语法是如何工作的。代码基本相同,只是语法不同。下面的链接可能对您有用