So what I'm trying to do is retrieve information from a Parse.com database based on an attribute other than objectID. More specifically, I'd like to retrieve an object without using the objectID so I can read its ADDRESS column. The logic so far:
Write a query that returns the row where the restaurant name is the same as 'resto'.
(this is where i'm stuck) retrieve the restaurant's address from the PFQuery and assign that String value to the addressLabel.text variable. Here is the code I have:
class FinalView: UIViewController{ var resto = 'Eddies Cafe' var address:String! //var phone:String! @IBOutlet var restoLabel: UILabel! @IBOutlet var addressLabel: UILabel! @IBOutlet var phoneLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() //the below query returns only one row var query = PFQuery(className: "Restaurants") query.whereKey("NAME", equalTo: resto) var obj = PFObject.getObjectWithID("i dont want this") address = obj["ADDRESS"] as? String restoLabel.text = resto addressLabel.text = address } }
I've been reading plenty on how to do it, but all i'm seeing is how to retrieve a PFObject from a query by it's objectID. I know the objectId's myself since it's my parse.com instance, but I need the app to be able to retrieve the data values from the backend based on restaurant name. Is there a way around this? Am I going about it all wrong? Thanks in advance.