Kunal Parekh
Kunal Parekh

Reputation: 370

Segue.destination does not show the target VC

enter image description here

I am trying to connect the 2 view controllers with prepare for segue. When I am writing the code in it, it does not want to prompt me the destination VC. In my other view controller, it was appearing it.

here is the code for segue

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "catView" {
            if let indexPath = self.tableView.indexPathForSelectedRow  {
                let value = subs[indexPath.row]

                print("value = \(value)")

                let controller = segue.destinationViewController as! Business_ViewController
                controller.cate_Id = value["id"] as! String
                controller.catTitleRec = value["NAME"] as! String
            }
        }
    }

Just to show the error on the code, so adding this screenshot

I am uploading one more image to show the structure of all my file. And as u can see the error on 2 line, i have written Business_ViewController, the error show Type'SubCategories' has no subscript member

enter image description here

enter image description here

Upvotes: 1

Views: 275

Answers (3)

David Seek
David Seek

Reputation: 17132

Try deleting your test targets if you're not using them. Sometimes this error occurs when test targets do not have some swift files that the app build target had in compile sources. The solution there was of course to add the file containing the 'undeclared type' to the test target or delete the test targets.

Upvotes: 2

Rob
Rob

Reputation: 437917

Your error is not telling you that there's anything wrong with the storyboard or the segue or anything like that. (If that were the problem, it would manifest itself as a runtime error).

This is a compilation error, telling you that it simply cannot find the class Business_ViewController. So double check that class definition and make sure you spelled that correctly. Make sure there are no compilation errors in that class. Also make sure that this file is included in the target that you're building. If this is an Objective-C class, make sure its header is included in your bridging header. It's going to be something like that, but without seeing how Business_ViewController was implemented, we can't diagnose the precise issue.

Upvotes: 2

Ketan Parmar
Ketan Parmar

Reputation: 27438

Set your segue indentifier(with relevant segue selected) as catView from asttribute inspector under storyboard segue set identifier as catView and second thing make sure that you have create Business_ViewController and set it to respective viewcontroller because compiler can't find Business_ViewController according to your second screenshot

Upvotes: 3

Related Questions