Reputation: 711
I created a tableview in storyboard that contains 11 rows. I want to be able to tap on each row and have it open up into it's own tableview controller, where I will store data, depending on the row tapped.
var array = ["row 1", "row 2", "row 3", "row 4", "row 5", "row 6", "row 7", "row 8", "row 9", "row 10", "row 11"]
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("prototypeCellIdentifier", forIndexPath: indexPath)
cell.textLabel?.text = array[indexPath.item]
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
return cell
}
This is what I have done to create the rows.
Upvotes: 0
Views: 833
Reputation: 812
In short:
show
To send data to the ViewController that's been shown by clicking a row, you should look into the method prepareForSegue(_)
Upvotes: 1