我正在以编程方式呈现一个视图控制器(SavedGames.swift - > OnePlayer.swift),我无法弄清楚如何更改我在原始控制器中呈现的视图控制器(OnePlayer.swift)中的数组(SavedGames) 。迅速)。我想在SavedGames.swift的代码块中更改OnePlayer中的tableData ..希望有意义
SavedGames.swift:
if let resultController = storyboard!.instantiateViewControllerWithIdentifier("OnePlayer") as? OnePlayer {
presentViewController(resultController, animated: true, completion: nil)
//in OnePlayer, set tableData to this tableData: [String] = ["one", "two", "three"]
}
OnePlayer.swift:
var tableData: [String] = ["zero", "zero", "zero"]
答案 0 :(得分:1)
这样做
if let resultController = storyboard!.instantiateViewControllerWithIdentifier("OnePlayer") as? OnePlayer {
resultController.tableData = ["zero", "zero", "zero"]
presentViewController(resultController, animated: true, completion: nil)
//in OnePlayer, set tableData to this tableData: [String] = ["one", "two", "three"]
}