Book Image

Application Development in iOS 7

By : Kyle Begeman
Book Image

Application Development in iOS 7

By: Kyle Begeman

Overview of this book

Table of Contents (15 chapters)
Application Development in iOS 7
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Displaying data


With our data loaded, we can now display the data in our custom cell. Scroll down to cellForRowAtIndexPath and let's set up our cell.

First, we need to grab the current food item from our array. We will do this using the indexPath.row parameter passed to cellForRowAtIndexPath. Add the following line of code below our cell allocation and before return cell:

// Create an instance of the current food item
NSDictionary *currentFoodItem = self.myFoodsArray[indexPath.row]; 

Now that we have currentFoodItem, we can start assigning our custom cells properties. Let's begin with the image. Add the following code to cellForRowAtIndexPath:

// Grab the image from the current food item and set the cell image
UIImage *foodImage = [UIImage imageWithContentsOfFile:currentFoodItem[@"image_filepath"]];
cell.foodImageView.image = foodImage;

Here, we simply allocate an image based on the image_filepath key we created for each food item. Next, we set this image as the current cell's image. Now, we...