Reputation: 61
I'm trying to develop my first app. This is kind of a restaurant and menu app. The first screen should be list of restaurants. This will list all the restaurants from Parse table. If one of the row(restaurant) is selected, it should segue to another view controller, but with chosen(restaurant's/personalized) menu. If any of the menu item is selected, then a third vc should open up with that menu details.
I've created story board design and segues, but not sure: 1) how to present restaurants from parse table into 1st VC ? 2) If selected, how to pass the resta.id from 1st vc to menuVc.
I've tried getting the table data from Parse to an array, but lost in how to pass it to didSelectRow in 1st VC and then to other VC respectively. Is there a way of taking the parse table data into rows for the restaurants table ?
var myRestaurant: [String] = [String]()
//Getting the data from the PFQuery class
var query = PFQuery(className: "Restaurants")
query.findObjectsInBackgroundWithBlock{
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
if let objects = objects as? [PFObject] {
for object in objects {
self.myRestaurant.append(object.objectForKey("ClassNameObject") as! String)
}
}
} else {
println("errorin fetching restaurant block")
}
}
Upvotes: 0
Views: 1141
Reputation: 3089
Great to hear you're getting started with app development!
This is a very common scenario and will be a breeze to accomplish with the right tools. You can build out your own functionality for Parse within a TableViewController or you can use Parse's own PFQueryTableViewController to accomplish exactly what you want very easily.
Check out a tutorial to help get you started
The gist of it is, you must query Parse for data to fill the TableViewController's data source. With PFQueryTableViewController, all you have to do is specify a query in the function queryForTable()
. PFQueryTableViewController is included in the ParseUI framework (along with a bunch of other great tools) which you will want to import.
Upvotes: 3