I want to use uitableview in tvos to show list of string data but compiler is throughing following errors in generated header:
"No type or protocol named 'UITableViewDataSource'" And "Attempting to use the forward class 'UITableView' as superclass of 'TWOSSelectionTableTVOS'"
Even though this code is working is ios .
My code structure is as follow :
SelectionTable.swift:
import UIKit
class TWOSSelectionTableTVOS : UITableView
{
private var vDataSrc:[String]!
func SetDataSrc (_ pDataSrc:[String])
{
self.vDataSrc = pDataSrc
}
func UpdateDataSrc (_ pStringList:[String])
{
self.vDataSrc += pStringList
}
func GetDataSrc () -> [String]
{
return self.vDataSrc
}
}
PaintUI.swift :
import UIKit
@objc
class PaintUI: NSObject,UITableViewDelegate, UITableViewDataSource {
static let uShared = PaintUI ()
@objc
static func updateUIMessage() {
DispatchQueue.main.async {
ExecuteInlineSelectionTable ()
}
}
func tableView (_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell (withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = "hello"
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let viewcontroller: TWIOSViewController!
viewcontroller = StaticContext.sViewController
}
public static func ExecuteInlineSelectionTable ()
{
let selectiontable:TWOSSelectionTableTVOS!
selectiontable = TWOSSelectionTableTVOS ()
selectiontable.register (UITableViewCell.self, forCellReuseIdentifier: "cell")
selectiontable.dataSource = uShared
selectiontable.delegate = uShared
selectiontable.isScrollEnabled = true
// TODO : will add selection table in view heriearchy but currently getting
// compilation error
}
}
And finally calling PaintUI.updateUIMessage () , it is throughing above errors for tvOS only but in case of ios code is working fine.