was hoping to get some help with identifying why my prepareForSegue() is not working.
Here is my Main.storyboard and the identifier for the segue. http://ift.tt/1MYNhVO
I am linking the Prototype cell as a selection segue (show) to a UITabBarController which will have a few UIViewController connect to it. I have placed breakpoints in the prepareForSegue and see that it never goes into the function, I have a suspicion that I may have setup the segue incorrectly but my inexperience in iOS development is causing me to overlook what the problem is.
Here is my prepareForSegue on my prepareForSegue() on my MainViewController
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showLesson" {
var tabBarVC: UITabBarController = segue.destinationViewController as UITabBarController
var descVC: LessonsDetailsViewController = tabBarVC.viewControllers?.first as LessonsDetailsViewController
var row = tableView!.indexPathForSelectedRow()!.row
var dataObj = lessonsNSMObj[row]
descVC.managedObject = dataObj
}
}
I did find a work around but I am not sure if that is the appropriate way of doing this or if there is downfall of doing it this way.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showLesson" {
var tabBarVC: UITabBarController = segue.destinationViewController as UITabBarController
var descVC: LessonsDetailsViewController = tabBarVC.viewControllers?.first as LessonsDetailsViewController
var row = sender as Int
var dataObj = lessonsNSMObj[row]
descVC.managedObject = dataObj
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
let row = indexPath.row
performSegueWithIdentifier("showLesson", sender: row)
}
Any help would be greatly appreciative! I also have the whole project available on github: http://ift.tt/1G0QKkI
Aucun commentaire:
Enregistrer un commentaire