O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required