-1

I am trying to perform segue "programmatically" but it keep giving me an error which says that my view controller has no segue with this id

this is part of my storyboard my storyboard

this is the method where I perform the segue

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
    self.performSegueWithIdentifier("show recipe details" , sender: self)
}

and this is the perform segue method

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
    if(segue.identifier == self.SEGUE_ID)
    {
        if((sender?.isKindOfClass(RecepieViewController)) != nil)
        {
            if(segue.destinationViewController.isKindOfClass(RecipeDetailsViewController))
            {
                print("seguee")
            }
        }
    }
}

what's wrong?

this is my storyboard xml file RecipeViewController

RecipeDetailsViewController

Cœur
  • 37,241
  • 25
  • 195
  • 267
user3703910
  • 624
  • 1
  • 5
  • 25

3 Answers3

0

Make sure you do not have a white space after "show recipe details" in the identifier name in the attribute inspector (ig.: "show recipe details ").

user3435595
  • 137
  • 1
  • 1
  • 9
0

Couple of questions:

  • Are you using the correct storyboard file? Is your storyboard file referenced in your Info.plist?
  • Are identifiers with spaces in their name actually allowed?
  • In one place you use the literal string "show recipe details" while in the other function you use self.SEGUE_ID. Why not use that constant in both places to avoid confusion.

Swift nit: You can more easily do the isKindOfClass() code in Swift as follows:

if let recipeViewController = sender as? RecepieViewController {
    if let recipeDetailsViewController = segue.destinationViewController as? recipeDetailsViewController {
        // Got the right view controllers
    }
}
Stefan Arentz
  • 34,311
  • 8
  • 67
  • 88
  • I found that xCode gave me 2 warnings which says : Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:. I don't know where this warning coming from , although I ran my app and it works perfect (except of the segue thing) , so I assume that yes Iam using the correct storyboard (I only have one !) and yes identifiers with spaces allowed (although I tried it in one word ) this is for testing so Iam wrote the string itself so I can make sure that Iam using the correct string . thx for the last tip – user3703910 Feb 25 '15 at 02:43
0

Display the storyboard as source (xml format) and then search for "show recipe details". This will confirm if the segue ID you expect is actually in the code or whether there is an extraneous character that creating the problem.

Syed Tariq
  • 2,878
  • 3
  • 27
  • 37