First, I have a protocol:
public protocol ContentList {
//...
}
and some struct
s:
public struct Post: ContentList {
//...
}
public struct Essay: ContentList {
//...
}
then I have a subclass of UITableViewController
:
open class MainTableViewController<T: ContentList>: UITableViewController {
// ...
func getData() -> [T] {
retrun ...
}
}
the UI part of this class, MainTableViewController
, was defined in Main.storyboard
, so I did this:
let kMainTableViewControllerIdentifier = "MainTableViewController"
let listController = (self.storyboard.instantiateViewController(withIdentifier: kMainTableViewControllerIdentifier) as? MainTableViewController<Post>)!
listController.dataSourceType = .post
and I got some error:
Unknown class _TtC5Elias23MainTableViewController in Interface Builder file.
Could not cast value of type 'UITableViewController' (0x1af463db8) to 'Elias.MainTableViewController<Elias.Post>' (0x101907af8).
Could not cast value of type 'UITableViewController' (0x1af463db8) to 'Elias.MainTableViewController<Elias.Post>' (0x101907af8).
I have no ideas about how to solve this so far. so I need some help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.