01.02.2014 Views

Objective-C Fundamentals

Objective-C Fundamentals

Objective-C Fundamentals

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

30 CHAPTER 2 Data types, variables, and constants<br />

Figure 2.2 The main project window in Xcode immediately after creating the Rental Manager application using<br />

the Navigation-based Application template<br />

View-based Application (as in the Coin Toss project from chapter 1). The Navigationbased<br />

Application template inserts a few user interface elements, such as a distinctive<br />

blue navigation bar at the top. As the Rental Manager application develops, you’ll<br />

extend the various features provided, but for now, let’s concentrate on adding the<br />

ability to display a list of rental properties.<br />

When you run the application, you may notice that the white background is<br />

divided into a number of rows by light gray lines, and by using your finger, you can<br />

slide the list up and down. This control was added by the project template and is<br />

called a UITableView. To display data in this control, you must write a small amount of<br />

code to specify how many rows it should add and what each row contains.<br />

Select the file named RootViewController.m and open it for editing. The project<br />

template has inserted a fair amount of source code into this file for your convenience<br />

(although, at present, most of it’s commented out).<br />

Locate the two methods named tableView:numberOfRowsInSection: and<br />

tableView:cellForRowAtIndexPath: and replace them with the code in the following<br />

listing.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!