在Swift中返回instancetype
我正在尝试进行此扩展:
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 }}但我得到编译错误:
错误:无法将'UIViewController'类型的返回表达式转换为返回类型'Self'
可能吗?我也想成为init(storyboardName: String, storyboardId: String)
慕田峪9158850
米琪卡哇伊
慕森卡
九州编程
随时随地看视频慕课网APP