我最近重构了我的课程BookTableViewController
来自简单的继承UITableViewController
,这样它现在继承自泛型类FetchedResultsTableViewController<TResultType, TCellType>
它本身继承自UITableViewController
.
类声明如下所示:
class BookTableViewController: FetchedResultsTableViewController<Book, BookTableViewCell> {
override func viewDidLoad() {
// breakpoints in here do not catch!
}
}
class FetchedResultsTableViewController<TResultType, TCellType: UITableViewCell>:
UITableViewController, NSFetchedResultsControllerDelegate {
// implementation here
}
在故事板中,自定义类和模块都已设置,我can单击箭头跳转到代码BookTableViewController
类,表明故事板已正确链接到该类。但是,当我尝试运行该应用程序时,该类无法识别 - 代码在viewDidLoad()
不运行,并且在运行我的应用程序时收到以下记录消息:
Interface Builder 文件中存在未知类 _TtC12Reading_List23BookTableViewController。
我正在运行 XCode 7.3 (Swift 2.2)。这是故事板的限制、错误还是我错过了什么?
Thanks!
UPDATE:
经过一番实验,它似乎确实与泛型继承有关,而不是与类的可访问性有关。定义了以下类:
import Foundation
import UIKit
// Both of these classes are accessible by the Storyboard
class FirstInheritance : UITableViewController{}
class SecondInheritance : FirstInheritance{}
// The generic class is also accessible
class GenericViewController<T> : UITableViewController{}
// But this class is not accessible...
class ConcreteViewController : GenericViewController<String>{}
除ConcreteViewController
建议在 Storyboard 的类自动完成中使用(尽管通用类也不起作用,因为无法在 Storyboard 中指定类型参数)。