asked on
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.item == 0)
{
performSegueWithIdentifier("repeatDaysSegue", sender: indexPath.item)
}
else if (indexPath.item == 1)
{
performSegueWithIdentifier("snoozeSegue", sender: indexPath.item)
}
}
It seems to be working OK, but now when the user clicks on the Repeat cell, you can see two Segues happen in the UI. Also, prepareForSegue() gets fired twice. First time the sender is a UITableViewCell, second time sender is Int. class AddEditAlarmViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
let array = ["Repeat", "Snooze"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("settingsCustomCell")! as UITableViewCell
cell.textLabel?.text = array[indexPath.item]
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.item == 0)
{
performSegueWithIdentifier("repeatDaysSegue", sender: indexPath.item)
}
else if (indexPath.item == 1)
{
performSegueWithIdentifier("snoozeSegue", sender: indexPath.item)
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "repeatDaysSegue")
{
let cellItem = sender as! Int
if (array[cellItem] == "Repeat")
{
let repeatDaysView = segue.destinationViewController as! RepeatDaysTableViewController
repeatDaysView.alarm = currentAlarm
}
}
}
}