I searched, but I didn't find a familiar answer, so...
I am about to program a class to handle parse methods like updating, adding, fetching and deleting.
func updateParse(className:String, whereKey:String, equalTo:String, updateData:Dictionary<String, String>) {
let query = PFQuery(className: className)
query.whereKey(whereKey, equalTo: equalTo)
query.findObjectsInBackgroundWithBlock {(objects, error) -> Void in
if error == nil {
//this will always have one single object
for user in objects! {
//user.count would be always 1
for (key, value) in updateData {
user[key] = value //Cannot assign to immutable expression of type 'AnyObject?!'
}
user.saveInBackground()
}
} else {
print("Fehler beim Update der Klasse \(className) where \(whereKey) = \(equalTo)")
}
}
}
As I am about to learn swift at the moment, I would love to get an answer with a little declaration, so that I would learn a little bit more.
btw: I later call this method like this:
parseAdd.updateParse("UserProfile", whereKey: "username", equalTo: "Phil", updateData: ["vorname":self.vornameTextField!.text!,"nachname":self.nachnameTextField!.text!,"telefonnummer":self.telefonnummerTextField!.text!])