我可以返回一个类的所有子类的列表吗?例如:
class Mother {
}
class ChildFoo: Mother {
}
class ChildBar: Mother {
}
let motherSubclasses = ... // TODO
print(motherSubclasses) // should to return [ChildFoo.self, ChildBar.self]
Run Code Online (Sandbox Code Playgroud) 最近我重构我的课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
}
Run Code Online (Sandbox Code Playgroud)
在Storyboard中,Custom类和Module都已设置,我可以单击箭头跳转到BookTableViewController类的代码,建议故事板正确链接到类.但是,当我尝试运行应用程序时,无法识别该类 - 代码输入viewDidLoad()未运行,并且在运行我的应用程序时收到以下记录的消息:
Interface Builder文件中的未知类_TtC12Reading_List23BookTableViewController.
我正在运行XCode 7.3(Swift 2.2).这是故事板的限制,一个错误,还是我错过了什么?
谢谢!
更新:
经过一些实验,它似乎与通用继承有关,而不是类的可访问性.定义了以下类:
import Foundation
import UIKit
// Both of these classes are accessible by the Storyboard
class FirstInheritance : UITableViewController{}
class SecondInheritance : FirstInheritance{} …Run Code Online (Sandbox Code Playgroud)