I just spent like two hours googling/stack overflowing trying to find a solution to no avail. I am using a view controller inside of which I have a tableview. It populates just fine. When you click on one cell, I want it to go to a different ViewController and load more information about that cell's contents.
override func prepareForSegue(segue: UIStoryboardSegue, sender:
AnyObject?) {
//This line keeps giving me an error - idk how to fix it
//UITablview(numberOfRowsInSection:Int)->'Int' does not have a member named 'indexPathForSelectedRow()'
var indexPath = tableView.indexPathForSelectedRow()
let AddPreferenceViewController : betatry1.AddPreferenceViewController
= segue.destinationViewController as betatry1.AddPreferenceViewController
AddPreferenceViewController.pref = preferences[indexPath]
}
I initialized pref in AddPreferenceViewController so that's not the problem
here are the other two required tableView methods
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//println(curUser["preferences"])
// tableView.rowHeight = UITableViewAutomaticDimension;
// tableView.estimatedRowHeight = 44.0;
var preferences : [String] = curUser["preferences"] as [String]
return preferences.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier( "Cell", forIndexPath: indexPath) as UITableViewCell
var preferences : [String] = curUser["preferences"] as [String]
current = preferences[indexPath.row]
cell.textLabel?.text = current
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
return cell
}
I basically need to pass the string at the index of which cell the user click to the AddPreferenceViewController.
Thanks for the help in advance