我正在尝试进行此扩展:
extension UIViewController
{
class func initialize(storyboardName: String, storyboardId: String) -> Self
{
let storyboad = UIStoryboard(name: storyboardName, bundle: nil)
let controller = storyboad.instantiateViewControllerWithIdentifier(storyboardId) as! Self
return controller
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到编译错误:
错误:无法将'UIViewController'类型的返回表达式转换为返回类型'Self'
可能吗?我也想成为init(storyboardName: String, storyboardId: String)