ios - How do I retrieve an array of a custom subclass of PFObjects stored under the PFUser.currentUser() -
i'm struggling retrieving array of pfobjects stored on pfuser.currentuser()
i have custom subclass of pfobject: unuser
here's how save array of [unuser] called favoritedrivers:
if let currentuser = pfuser.currentuser() { currentuser["favoritedrivers"] = favoritedrivers currentuser.saveinbackgroundwithblock({ (succes: bool, error: nserror?) -> void in if succes { } }) }
if retrieve entry this:
if let currentuser = pfuser.currentuser() { var objects = currentuser["favoritedrivers"]
println(objects) shows in console (the array in trial has 1 entry):
optional(("<unuser: 0x174138920, objectid: megjallla9, localid: (null)> {\n}"))
what best way fetch referred pfobjects , store them in array of unuser?
this tried:
var relation = currentuser.relationforkey("favoritedrivers") relation.query()!.findobjectsinbackgroundwithblock{ ( objects: [anyobject]?, error: nserror?) -> void in if error == nil { let favoritedrivers = objects as? [unuser]
you're setting array need read array, not relation.
your array array of pointers, want, need ensure have of data pointers default (and can see in log) class type , object ids.
to that, array , call fetchallifneededinbackground:block:
array. update of objects in array need current data server. kind of relation query...
Comments
Post a Comment