1

enter image description hereenter image description hereHere is my my Xcode project. I have already hooked this up to firebase, but I keep getting the error:

2017-11-28 12:37:38.478475-0500 RatFinder_ios[1099:21397] ***
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<FIRDatabaseReference 0x600000853170> setValue:forUndefinedKey:]: 
this class is not key value coding-compliant for the key City.'

I am very confused because I have followed all the coding-compliant rules and have made sure the information passed into the function is:

func writeToFirebase()
{
    let refRats = Database.database().reference()
    let key = refRats.childByAutoId().key
    guard let dateText = dateTextField.text, let boroughText = boroughTextField.text, let locationTypeText = locationTypeTextField.text, let addressText = addressTextField.text, let cityText = cityTextField.text, let zipText = zipTextField.text, let latitudeText = latitudeTextField.text, let longitudeText = longitudeTextField.text, let createdDateIntText = createdDateInt() else { return }
    //creating rat with the given values
    let rat: [String: Any] = Sighting.init(createdDate: dateText, createdDateInt: createdDateIntText, incidentAddress: addressText, locationType: locationTypeText, incidentZip: zipText, city: cityText, borough: boroughText, latitude: latitudeText, longitude: longitudeText).toDictionary()

    refRats.child(key).setValuesForKeys(rat)
}
Fhead
  • 11
  • 2
  • Please point out the exact line of code causing the error. – rmaddy Nov 28 '17 at 18:02
  • When I use the debugger the I see this I just added a screenshot of the image I see to the original question . class AppDelegate: UIResponder, UIApplicationDelegate { – Fhead Nov 28 '17 at 22:02
  • Your image is not showing the import details about the error. See the stack trace in the debugger console? Scroll that and exand it so we can see the whole stack trace and then update your picture with that info. – rmaddy Nov 28 '17 at 22:07
  • Ok I have just updated it – Fhead Nov 28 '17 at 22:09

0 Answers0