ios - How to add data to object when keys retrieve only 1 object? PARSE.COM SWIFT -


okay have classnamed: "privategroups". each row in privategroups contains "groupname" , "password". in uiview, if user enters groupname , password , hits submit, want add user objectid specific groupname/password entry under "members".

this code have isn't working:

var query = pfquery(classname: "privategroups")  query.wherekey("privatename", equalto: joinname.text)  query.wherekey("password", equalto: joinpassword.text)  query.findobjectsinbackgroundwithblock { (objects, error) -> void in  if objects.count == 1 {  object in objects {  query.getfirstobject().adduniqueobject(pfuser.currentuser().objectid, forkey: "members")  query.getfirstobject().saveinbackground() }} 

this classname looks like

so if match "members" , "password" , press button, want add user's object id "members"

in loop for object in objects shouldn't need call query.getfirstobject() since have object. instead, try

for object in objects {        if let arr = object["members"]{           if(arr.containsobject(pfuser.currentuser().objectid == false){              arr.addobject(pfuser.currentuser().objectid)              object.saveinbackground()           }        }    } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -