0

I have a view controller where users make posts via Parse. I want to add a request button which would save the users they add to a tableview in another view controller (like a list), I don't know how to go about this, do I create a new class in Parse which points to the User Class or do I use a relation (which I don't know how to use).

   @IBAction func addUser(sender: AnyObject) {

    //This is the add button in my tableview cell 

}

In my user posts I have there username in a label cell.userName.text = user["username"] as? String

When I hit the add button I want to store that user name in a list that belongs to the current user or relation.

In my new view controller lets call it "Favorites" I want to query that list of added users of the current user.

Thanks!

kareem
  • 903
  • 1
  • 14
  • 36
  • https://www.parse.com/questions/get-pfuser-in-pfquery-using-ios-api – ericgu Jan 16 '15 at 03:07
  • @swiftshokunin right, this is useful but i cant really connect the obj c to the swift, I am trying to do this in swift plus I feel like I have an extra step in my scenario I want to add then in my other Favorites query all the adds. – kareem Jan 16 '15 at 03:19

1 Answers1

1

https://parse.com/questions/pointer-vs-relation

This is the main difference I found between a relation and a pointer. Since you only want one user per post you probably want to use a pointer for the post class. I am assuming that when the current user logged in hits the addUser button you want to save the creator of the post to the currently logged in user class in a list within the user object?

If that is the case then you want a relation in the user class to add the creators of posts that the currently logged in user liked.

Can you post the code you are having trouble with?

  • So not quite. I just want to store the creator of the post in a way that I can query all the added users for each currently logged in user, how I do it is what I need help with so there is not really any code to show. – kareem Jan 16 '15 at 04:48
  • You can store the username of the creator into the post class with a column not a pointer, if you wanted other information such as image of the creator you can create another column in the post class and store it there as well. When the currently logged in user addUser button then you would add to your list of usernames and images of those users to a list within the user class (no relation needed). When it comes time to displaying the list just pull form the user class, display the username and image. If the user selects one of those users then it could link to that user through the username. – JMStudios.jrichardson Jan 16 '15 at 05:11