views:

52

answers:

2

I have a tab bar application. In one of my tabs, there is a search bar and a table view below that. When you enter something into the search bar, it returns parsed xml. I need to put this parsed information into the tableview below. The class inherits from UIViewController. I declared a UITableView object in the header file and linked it in interface builder, and adopted the UITableViewDelegate protocol.

I'm not sure If i'm going about this the correct way. Any help?

A: 

That sounds about right. You will need to also have your UIViewController implement UITableViewDataSource, and add the methods from that protocol to populate the table.

Joe Cannatti
So all of this would be in my interface heading?@interface Search : UIViewController <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource>
Liam
yep, thats correct
Joe Cannatti
be sure to link the datasource and delegate outlets in IB too
Joe Cannatti
Can you be more specific as to what i must link? I'm pretty much a total noob. Thanks :)
Liam
In IB, Control+click and drag from your UIViewController to the UITableView and then selected 'delegate'. Do the same thing again and select 'datasource'. Then as long as you implement the datasource methodsyou should be good.
Joe Cannatti
In this particular xib file there is only a File's Owner, First Responder, And View. I tried connecting with View but the app crashed.
Liam
A: 

There are various tutorials available which guide you step-by-step to create a simple tablview. Google them. You can follow these steps for connecting your tableView outlets:

  1. Select your viewController where you are displaying the tableview to be your "File's Owner" in Identity Inspector.

  2. Drag your view's outlet to your File's owner.

  3. For tableView inside view, drag its outlets to File's owner again so that your datasource and delegates are up. And in the same view, drag your referencing outlet to the IBOutlet you have created in your viewController class.

neha