Cover by Joe Conway, Aaron Hillegass

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required