目标:制作一个通用的ViewController和TableViewController,它们能够从现有的storyboard中返回自己,并且可以成为其他视图控制器的子类,允许它们使用这个功能。
class GenericTableViewController: UITableViewController
{
//MARK: Storyboard
class func storyboardName() -> String
{
return ""
}
class func storyboardIdentifier() -> String
{
return ""
}
class func existingStoryboardControllerTemplate() -> Self
{
return UIStoryboard.storyboardWithName(storyboardName()).instantiateViewControllerWithIdentifier(storyboardIdentifier()) as! Self
}
}
问题是...编译器强制我将Self更改为这个"GenericTableViewController",如果我更改它...它会抱怨我不再返回"Self"。
有什么办法可以解决这个问题吗?