hacker
hacker

Reputation: 8947

How to load two arrays into the same tableview?

I have an iPhone application in which I want to add two arrays to the same tableview, ie news array and deals array, which are returned by a web service. I need to load them in the same view, ie in a tableview, as if loading from a single array. Can anybody help me in achieving this?

Upvotes: 5

Views: 970

Answers (2)

hacker
hacker

Reputation: 8947

Finally I soted it out like this.First take the two arrays.then merge it in to one array,and load the table view from that array.if u need seperate actions then in your didselect methode check whether the object contains in the first array then do something,else do another thing ...

Upvotes: 1

Alex Reynolds
Alex Reynolds

Reputation: 96937

Put code in the delegate methods which treats the news and deals arrays as two separate sections. For example, use the -tableView:cellForRowAtIndexPath: to populate a first set of cells with news index paths and a second set of cells with deals index paths. Look at the UITableViewDataSource delegate protocol.

Upvotes: 0

Related Questions