Chapter 18. Adding data to your LioN app

 

This chapter covers

  • Adding hardcoded data to your LioN app
  • Refactoring to be MVC compliant
  • Showing the description on the cell

You created the foundation of the LioN app in the last chapter, and you’re going to add more functionality to it in this chapter. I told you about my approach in chapter 17: you’ll code, test, refactor, and then do it all over again. You may want me to show you the final output, but this iterative development is part of the process. If you try to code a big chunk of functionality all at once, you won’t know which parts work and which don’t when you test it. You’ll have to walk through everything you wrote to find the error. It’s much easier to start small, test, refactor, and add more.

In this chapter, you’re going to continue with this process by first adding some data to an array and displaying it in the table, and then refactoring the data to separate the model from the view from the controller (the MVC pattern was discussed in chapter 17).

18.1. Adding hardcoded data to your LioN

You hardcoded a single cell of data in chapter 17, and now you’re going to hardcode several cells of data so you can wire up your data source. You’ll do the following:

  1. Create an array.
  2. Hardcode some data.
  3. Create a LioN object to store data.
  4. Make the array the data source for the table, and then test it.

Ready? Let’s get to it!

18.1.1. Creating an array of dummy data

18.2. Adding a model to the mix

18.3. Changing the layout of the table cell

18.4. Summary