I am trying to make Vocab app. first ViewController is a static tableView, user can choose date of word that you want to memorize. All day_vocabulary arrays are in the this ViewController, one array contains 30 vocabularies, I have vocab for 90 days.
when user chooses a date, This ViewCotroller passes an array to the another View that will display 30 vocabularies. Here, I tried to pass a specific data to another ViewControl with using 90 segues, It doesn't look good at all. Also I tried to use didSelectRowAtIndexPath like this,
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.section == 0 && indexPath.row == 0 {
performSegueWithIdentifier("dayVocab1", sender: nil )
}
}
I realized that I can't set identifier of segue without using storyboard by reading another post, So the result will be same.
I want to know that passing specific data with using only one segue.
Here is my another code for prepareFor segue.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "dayVocab1") {
let destViewController : ViewController = segue.destinationViewController as! ViewController
destViewController.vocabData = vocab_day1p1
destViewController.meaningData = meaning_day1p1
}
if (segue.identifier == "dayVocab2") {
let destViewController : ViewController = segue.destinationViewController as! ViewController
destViewController.vocabData = vocab_day1p2
destViewController.meaningData = meaning_day1p2
}
}
I think using sender is the key of solution,
please let me know what would be the best solution for this.
Thank you.