I am having a strange problem. I am trying to assign a dataSource to a table programatically.
I have created a UITableView and an IBOutlet for it in my
Change your code to:
class ViewController: UIViewController
{
@IBOutlet weak var table: UITableView!
var dataSource: MyData?
override func viewDidLoad()
{
super.viewDidLoad()
dataSource = MyData()
table.dataSource = dataSource!
}
}
Your app breaks because the ds is deallocated as soon as viewDidLoad returns. You have to keep a reference to your data source.