ios - User's friend list tableview is empty and parse query did not return any data -


this code in swift

class userviewcontroller: uitableviewcontroller {  var userarray: nsmutablearray = []  @iboutlet weak var friendlisttableview: uitableview! override func viewdidload() {     super.viewdidload()         retrievemessages()     } func retrievemessages() {     var query = pfuser.query()     if let username = pfuser.currentuser().username {         query.wherekey("username", equalto: username)         query.findobjectsinbackgroundwithblock {         (objects, error) -> void in          object in objects! {             let usernames:string? = (object pfobject)["friends"] as? string             println(usernames) // prints nil             if usernames != nil {                 self.userarray.addobject(usernames!)             }         }                 dispatch_async(dispatch_get_main_queue()) {                     self.friendlisttableview.reloaddata()                 }      }  } }             override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }  // mark: - table view data source  override func numberofsectionsintableview(tableview: uitableview) -> int {     // #warning potentially incomplete method implementation.     // return number of sections.     return 1 }  override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {     // #warning incomplete method implementation.     // return number of rows in section.     return userarray.count }   override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {      // update - replace as!      let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) uitableviewcell      cell.textlabel?.text = userarray[indexpath.row] as? string      return cell } 

i've saved current user's friend list pfrelation in class "user" in column "friends", here's how save

class adduserviewcontroller: uiviewcontroller {  @iboutlet weak var usernametextfield: uitextfield!  @ibaction func adduser(sender: anyobject) {     var query = pfuser.query()     query.wherekey("username", equalto: usernametextfield.text)     println("pass")     query.getfirstobjectinbackgroundwithblock{ (object:pfobject!, error: nserror!) -> void in          if error == nil {             let currentuser = pfuser.currentuser()             let friendlist = currentuser.relationforkey("friends")              var addfriend = object             if addfriend != nil {                 friendlist.addobject(addfriend)                 println("added")             }             pfuser.currentuser().saveinbackgroundwithblock{                 (succeeded: bool!, error: nserror!) in                  if error != nil {                     println("error")                 }                 else {                     println("saved")                 }             }         }      } } 

and want retrieve current user's friend list show in tableview problem can't update tableview show current user's friend list, it's empty , there's no user list in tableview @ all. code correct method? if not please me correct code

here's screenshot of user's class table in parse parse user list

here's screenshot of current user's friend in parse save pfrelation parse friend user list appreciated, thank you!

i haven't used parse in while, if i'm not mistaken, first query (in first chunk of code) isn't built correctly. should this:

 var query:pfquery = pfquery(classname: "user")  if let username = pfuser.currentuser().username {    query.wherekey("username", equalto: username)    query.findobjectsinbackgroundwithblock {....}  } 

the difference here query current user's username , not object itself. help?


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -