O'Reilly logo

RubyMotion iOS Development Essentials by Abhishek Nalwaya, Akshat Paul

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Search restaurant by city

In the previous section we were only showing restaurants in Chicago. If you noticed, it was hardcoded in the URL itself and was not generic. In this section we will make the application more generic and allow the user to search data based on a parameter city.

Update restro_controller.rb as follows:

class RestroController < UITableViewController def viewDidLoad super @restaurants = [] searchBar = UISearchBar.alloc.initWithFrame(CGRectMake(0, 0, self.tableView.frame.size.width, 0)) searchBar.delegate = self; searchBar.showsCancelButton = true; searchBar.sizeToFit view.tableHeaderView = searchBar view.dataSource = view.delegate = self searchBar.text = 'Chicago' searchBarSearchButtonClicked(searchBar) end def searchBarSearchButtonClicked(searchBar) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required