Adding Rows

There are a number of ways to add rows to a table view at runtime. The built-in behavior for adding a row is to display a new row with a green plus sign icon. However, this technique has fallen out of favor because it’s cumbersome to enter editing mode and then find the row with the plus sign icon – especially in large tables.

So we’re going to use the New button in the header view instead. When this button is tapped, a new row will be added to the UITableView. In ItemsViewController.m, implement addNewItem:.

-​ ​(​I​B​A​c​t​i​o​n​)​a​d​d​N​e​w​I​t​e​m​:​(​i​d​)​s​e​n​d​e​r​ {​ ​ ​ ​ ​/​/​ ​M​a​k​e​ ​a​ ​n​e​w​ ​i​n​d​e​x​ ​p​a​t​h​ ​f​o​r​ ​t​h​e​ ​0​t​h​ ​s​e​c​t​i​o​n​,​ ​l​a​s​t​ ​r​o​w​ ​ ​ ​ ​i​n​t​ ​l​a​s​t​R​o​w​ ​=​ ​[​[​s​e​l​f​ ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.