Chapter 27. Search your LioNs

 

This chapter covers

  • Adding search functionality
  • Closures
  • Cleaning up the code

Can you believe how far you’ve come in this book? You’re almost finished with the LioN app. It would be really nice if you allowed your users to search for the LioNs they’ve added—otherwise they’ll have to scroll through everything. Let’s see how to add that feature!

27.1. Adding the search functionality

The first thing you need to do is add the search bar to the LioN scene. Search the Object Library for search, and two different objects will be returned. The first is Search Bar, which is just the visual component, and the second is Search Bar and Search Display Controller. You want the second component, because you can use the controller to capture and manage users’ searches. Grab the Search Bar and Search Display Controller, and drop it at the very top of the table view on the MainViewController scene, above the words Prototype Cells. It should automatically take up the entire scene horizontally, as shown in figure 27.1.

Figure 27.1. The Search Bar and Search Display Controller should be dropped directly above the words Prototype Cells. The component will resize itself to span the entire scene horizontally.

27.2. Filtering LioNs based on user input

27.3. Searching other fields

27.4. Summary

27.5. Where do you go from here?