Reference to a TableView Delegate Object within a Scene in Swift 4

Multi tool use
Reference to a TableView Delegate Object within a Scene in Swift 4
I have a tableview in a SpriteKit scene. Using a tableview delegate method, I like to pass to another scene/ViewController, which cell was selected. There is only a single storyboard as this is entirely a SpriteKit game.
//TableView inside Scene & Delegate Protocol:
protocol gameSelectedDelegate {
func theGameSelected(gameInt: Int)
}
class GamesTableView: UITableView, UITableViewDelegate,UITableViewDataSource {
//Test Data
var items: [String] = ["Player1", "Player2"]
let defaults = UserDefaults.standard
var gamesList = [Game]()
var passedGame: Int?
//instance of delegate
var selectionDelegate: gameSelectedDelegate!`
//GameScene to receive tableview data and delegate for my tableview
class GamePlay: SKScene, gameSelectedDelegate {
var backButton = SKLabelNode(fontNamed: "ArialRoundedMTBold")
var score = SKLabelNode(fontNamed: "ArialRoundedMTBold")
var passedGame = 0 //Not getting passed from LoadGame
var passedGameDelegate:Int? = nil
override func sceneDidLoad() {
let grid = childNode(withName: "grid")
grid?.zPosition = 1
self.backgroundColor = UIColor.black
let sc = GamesTableView.self //How do I get a reference to my tableview?
sc.selectionDelegate = self
UITableView
UIViewController
UITableView
UITableViewController
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Your question isn't very clear. Why did you subclass
UITableView
? You either want to subclassUIViewController
and put aUITableView
in it, or you want to subclassUITableViewController
. How do the table view and the sprite kit scenes relate?– Paulw11
Jul 2 at 2:15