I seemed to have found another situation that causes the famous "Unknown class in Interface Builder file."
I tried fixing this problem using all the suggestions people posted in the plethora of other Q/A's regarding this bug and none of them worked.
I have stripped down the code as much as possible to isolate the problem. Here it is:
Code that causes error:
Class 1:
import UIKit
class TableViewControllerSubclass<T:Any>:UITableViewController{
}
Class 2:
import UIKit
class TableViewControllerSubclassChild:TableViewControllerSubclass<Int>{
override func viewDidLoad() {
super.viewDidLoad()
}
}
Main StoryBoard has single UITableViewController that inherits from TableViewControllerSubclassChild
. Here is a screen shot:
When I run the project as is I get the following output in the console:
2017-04-13 15:50:30.226 TableViewControllerBug[6087:165667] Unknown class _TtC22TableViewControllerBug32TableViewControllerSubclassChild in Interface Builder file.
and the breakpoint viewDidLoad
is never hit.
Now if you remove the use of generics in both classes and run the project there is no output to the console and the breakpoint at viewDidLoad
is hit.
Code that does NOT cause error
NewClass 1:
import UIKit
class TableViewControllerSubclass:UITableViewController{
}
NewClass 2:
import UIKit
class TableViewControllerSubclassChild:TableViewControllerSubclass{
override func viewDidLoad() {
super.viewDidLoad()
}
}
Here is the project with the code
My questions:
Is this a bug with Xcode/Interface builder? Or does the problem stem from illegal use of generics?
If this is illegal use of generics how does go about using generics properly in this situation?
If this is a bug, does anyone know of a work around?
Any insight into the problem will help! Thanks!