0

I'm getting this error in "RoomTableViewController.swift", this is the prepare for segue function to go from this TVC to another one called ItemTableViewController

I tried checking my segue identifiers thinking there is a problem with it but no luck! I also tried other solutions on stackoverflow.

I had it working earlier, but I don't know what I did to break it. The error is:

value of type 'ItemTableViewController' has no member 'selectedRoom'

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "segueRoomTVC" {

    //Figure out which row was tapped
    if let row = tableView.indexPathForSelectedRow?.row {

        let tappedProperty = Property.getAllProperties()[row] as! Property

        //Figure out the destination viewController
        let roomTVC = segue.destinationViewController as! RoomTableViewController

        //Pass the object for that row to the next viewController
        I'm getting the error here ---> roomTVC.selectedProperty = tappedProperty

    }

  }
}

Let me know if you need more of my code to be submitted here

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
Mustafa
  • 152
  • 2
  • 15
  • The problem is with ItemTableViewController , your RoomTableViewController that it is , first you are confusing your question with what is your currentTVC and what is your destination – Sourav Sachdeva Oct 31 '16 at 02:47
  • It's not like I edited this file and made mistake, but I think I added something to the code somewhere else and that broke this one. – Mustafa Oct 31 '16 at 02:47
  • @SouravSachdeva I didn't get your answer, can you explain to me what seems to be the problem? – Mustafa Oct 31 '16 at 02:48
  • do you mean the error is referring to `RoomTableViewController` and `selectedProperty`? Or have you included the wrong snippet of code? if so then what the error means is `RoomTableViewController` has no property named 'selectedProperty'... use cmd-f and search that class for "selectedProperty" to see if you have named it anywhere. If you have named it somewhere, then verify the scope allows it to be read in `prepareForSegue` – MikeG Oct 31 '16 at 02:50
  • try `var roomTVC = RoomTableViewController()` for setting the value `selectedProperty` of roomTVC – Jacky Shek Oct 31 '16 at 02:54
  • @JackyShek That did work :( – Mustafa Oct 31 '16 at 03:16
  • @MikeG I tried that, but still didn't work. I'm wondering if adding another segue and other tableViews broke it? – Mustafa Oct 31 '16 at 03:17
  • The answer is work or not? – Jacky Shek Oct 31 '16 at 03:25
  • @JackyShek I'm sorry did NOT work haha – Mustafa Oct 31 '16 at 03:30
  • It may help you. Please try http://stackoverflow.com/questions/26089152/sending-data-with-segue-with-swift – Jacky Shek Oct 31 '16 at 03:31

1 Answers1

0

I figured it out, I was passing the wrong data to the next VC. Thanks for your help guys!

Mustafa
  • 152
  • 2
  • 15