How To Add Delete Data From TableView In iPhone

In this application we will see how to add delete data from the tableview. Let see how it will worked.

Step 1: Create a new application using View base template. Give the application name “AddDelete”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the AddDeleteViewController class for you. Expand Resources and notice the template generated a separate nib, AddDeleteViewController.xib, for the “AddDelete”.

Step 4: In the AddDeleteAppDelegate.m file make the following changes:




Step 5: Open the AddDeleteViewController.h file, in this file we have added two protocols that are needed for it to act as the delegate and datasource for the table view,declare UITableView for displaying the list of data and NSMutableArray for insertion and deletion operations to the basic array handling and added one IBAction: method.




Step 6: Double click your AddDeleteViewController.xib file and open it to the Interface Builder. First drag the tableview from the library and place it to the view window, select the tableview from the view window and bring up connection Inspector, then you’ll notice that the first two available connections fare dataSource and delegate. Drag from the circle next to each of those connections over the File’s Owner icon. Now select the File’s Owner icon from the main window and bring up Connection Inspector and drag from the tableView to TableView. You have done all the connection, so save the .xib file, close it and go back to the Xcode.

Step 7: In the AddDeleteViewController.m file make the following changes :




Step 8: Now compile and run the application in the Simulator.

You can Downloaded SourceCode from here AddDelete 2