Reputation: 173
I have been trying to segue to a UICollectionViewController when I select a cell in my table view in a UIViewController with the following code:
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
if let resultController = storyboard.instantiateViewControllerWithIdentifier("PhotosViewController") as? PhotosViewController {
presentViewController(resultController, ANIMATED: true, completion: nil)
}
}
I keep getting an error saying UIStoryboard? does not have a member named 'instantiateViewControllerWithIdentifier'
I have imported the UIKit. I am just not sure why it is not recognizing that member.
Thanks
Upvotes: 0
Views: 39
Reputation: 6377
storyboard
is an optional, you should use optional chaining to access it.
if let resultController = storyboard?.instantiateViewControllerWithIdentifier("PhotosViewController") as? PhotosViewController {
presentViewController(resultController, animated: true, completion: nil)
}
Upvotes: 1