0

This is my first time ever using Parse, and I'm slightly confused about something. I'm currently trying to implement a feature that allows a user to add a friend. I need to make sure that the user they are trying to add exists, but I can't find how to do it. I know i need to make a query, but other than that I am completely lost...

What do I need to do in order to make sure this user exists? I have tried looking online but everything I can find is in Objective C and I don't understand it...

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Cesar
  • 115
  • 3
  • 10
  • You may be interested in this StackOverflow post. It shows how to create a UISearchController (search bar + table) for searching Parse by username and displaying the results. https://stackoverflow.com/questions/32356676/smart-search-for-parse-usernames-in-swift-not-working/32359180#32359180 – Russell Dec 07 '15 at 15:55

1 Answers1

0

After about an hour... I came up with what to do:

    var query = PFUser.query()    // submit the query
    query!.whereKey("username", equalTo:username) 
    do { 
        try query?.getFirstObject()
            // what to do if the object does exist
    } catch {
           // what to do if it doesn't
    }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Cesar
  • 115
  • 3
  • 10