Swift, Firebase: `setValue` giving error "AnyObject cannot be used with Dictionary Literal"
<p>I am experiencing an error <code>Contextual type AnyObject cannot be used within dictionary literal</code> in that func <code>addPet</code> down there, while trying to populate database with the <code>newPet</code> argument constituents in a dictionary.</p>

<pre><code>import Foundation
import Firebase

struct Pet {
    var name:String?
    var type:String?
    var age:Int?
    var feedingList:[String]
    var walkingList:[String]
}

struct User {
    var currentId:String?
    var numberOfPets:Int?
    var pets:[Pet]

}

class petBrain {

    var reff = FIRDatabaseReference()
    var currentUser:User = User(currentId: "",numberOfPets: 0,pets: [])

    init(){
        self.reff = FIRDatabase.database().reference()
    }

    func setUserId(cId:String?){
        self.currentUser.currentId = cId
    }

    func addPet(newPet:Pet) {
        self.reff.child("pets").childByAutoId().setValue(["name":newPet.name, "type":newPet.type, "age":newPet.age, "fList":newPet.feedingList, "wList":newPet.walkingList])
    }


}
</code></pre>

<p>I have already done this in other viewController, similarly for users and its working fine in dictionary shape (producing no error)</p>

<pre><code>    let em = emailTextField.text!
    let us = usernameTextField.text!

    ...

else {
    print("User created! Loging in.")
    self.login()
    // adding user to DB of users 
    self.ref.child("users").child(user!.uid).setValue(["email":em, "username":us])
}
</code></pre>

<p>What did i do wrong in the pets case? its maybe due to struct, or struct element types? Are those two structs well defined?</p>