1

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

Kunal Parekh
  • 380
  • 6
  • 24
  • are you sure your identifier name is `catView` or else – Anbu.Karthik Oct 14 '16 at 05:24
  • sorry I got this screenshot earlier. I had `catView` but then I changed it to `subcatView` – Kunal Parekh Oct 14 '16 at 05:25
  • can you attach your project , we will check – Anbu.Karthik Oct 14 '16 at 05:27
  • how can i attach the project? – Kunal Parekh Oct 14 '16 at 05:28
  • `Business_ViewController` named class exists? – Bista Oct 14 '16 at 05:29
  • see this once http://stackoverflow.com/questions/25437891/use-of-undeclared-type-in-swift-even-though-type-is-internal-and-exists-in-s – Anbu.Karthik Oct 14 '16 at 05:29
  • For the last errors, you need to explicitly say that `value` is a `[String:String]` (or `[String:Any]`), I don't know what it is really. And you are missing the `import` of `Business_viewController` – Larme Oct 14 '16 at 07:18
  • I am not missing any imports, I guess. However, this 2 errors together are pointing out to the models which i created. – Kunal Parekh Oct 14 '16 at 07:25
  • @Anbu.Karthik , for personal reason i dont use english. hi bro, intha user oru spam. enakku job tharatha solli 60 of intha project oda code vangitu enayum daily call panni thitran. ithu ponnu illa. Enakku enna pandradhu nu therla bro. edhachum idea sollungal. inga enakku sambalam illa. athan konjam illa rombavae emanthuttan. avanuta spam phone irukku. australian – Rajamohan S Nov 09 '16 at 00:52
  • @MohanSingh - call me my no 8754 846 846 – Anbu.Karthik Nov 09 '16 at 04:06

3 Answers3

3

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

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Well when I am writing the code `let controller = segue.destinationViewController as! ` after as it doesnot show my Business_ViewController. Please see the 2 image I uploaded – Kunal Parekh Oct 14 '16 at 05:37
  • @SarahMalik : this is the problem with your `Business_ViewController`, compiler can't find it. So, make sure what is wrong!! have you created these class properly ? is there any spelling mistake ? – Ketan Parmar Oct 14 '16 at 07:06
  • I have uploaded another screenshot which shows the errors and the structure of my files. May be this can help? – Kunal Parekh Oct 14 '16 at 07:17
2

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.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • thanks. its in pure swift. i have 3 main VC (Group, Sub-Group and Sub of sub group). I m trying to use the segue in the sub group. my segue works fine in the first VC, now trying to navigate from second to third. When i use Business_ViewController, both in the first and second VC its not showing the name, however if i use in the third VC, the name appears. It seems like my 3rd VC is outside their domain – Kunal Parekh Oct 14 '16 at 07:08
2

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.

David Seek
  • 16,783
  • 19
  • 105
  • 136