I recently refactored my class BookTableViewController
from a simple inheritance from UITableViewController
, so that it now inherits from a generic class FetchedResultsTableViewController<TResultType, TCellType>
which itself inherits from UITableViewController
.
The class declarations look like this:
class BookTableViewController: FetchedResultsTableViewController<Book, BookTableViewCell> {
override func viewDidLoad() {
// breakpoints in here do not catch!
}
}
class FetchedResultsTableViewController<TResultType, TCellType: UITableViewCell>:
UITableViewController, NSFetchedResultsControllerDelegate {
// implementation here
}
In the Storyboard, the Custom class and Module are both set, and I can click the arrow to jump to the code for the BookTableViewController
class, suggesting that the storyboard is linked correctly to the class. However, when I try to run the application, the class is not recognised - code in viewDidLoad()
does not run, and I receive the following logged message when running my app:
Unknown class _TtC12Reading_List23BookTableViewController in Interface Builder file.
I am running XCode 7.3 (Swift 2.2). Is this a limitation with Storyboards, a bug, or have I missed something?
Thanks!
UPDATE:
After some experimentation, it does seem to be related to the generic inheritance, rather than the accessibility of the class. With the following classes defined:
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>{}
all classes except the ConcreteViewController
are suggested in the Storyboard's class autocomplete (although the generic class also does not work, as there is no way to specify the type arguments in the Storyboard).