Reputation: 65
First of all, let me say that this is a noobish question so please bear with me here :D. I have a tableview embedded in a navigation control and it is my main view. There is an "Add" button where I can add "things" then when that is triggered it shows the added item on the table view and also switches back to the main view controller with the code below
@IBAction func buttonAddPost_Click(sender: UIButton) {
postMgr.addPost(titleBox.text, description: descriptionBox.text, postDate: date)
self.navigationController.popToRootViewControllerAnimated(true)
}
Again the above code takes me back to the main table view controller just fine.
But when I click on a cell to take me to a more detailed view, the app crashes. Here is the code
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
let listingPage = self.storyboard.instantiateViewControllerIdentifier("listingPage") as PostListingTableViewController
self.navigationController.pushViewController(listingPage, animated: true)
}
"listingPage" is the storyboard ID for the new view controller I'm trying to go to. I have used the above technique a few times somewhere else and worked just fine but I'm not sure what's wrong here.
Error I get: Thread 1 0 swift_dynamicCast and it highlights 0x1d7150: pushl %ebp Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT) 1 2 Exchange.PostlistTableViewController ([app name].[class name]) and it highlights the didselectrowatindexpath . . .
Please help...
KM
Upvotes: 0
Views: 2881
Reputation: 114808
The exception tells you what the problem is - You are casting the view controller as PostListingTableViewController
but the object type that is returned is PostlistTableViewController
so the cast generates an exception.
You need to determine what the correct class name is and either update your storyboard or your didSelectRowAtIndexPath
so that they are consistent - either Postlist or PostListing.
Upvotes: 1