views:

23

answers:

1

I've made a new class in my Xcode project which is derived from UITableView

I then drag a UITableView from in the interface builder onto my view and change the class of the object to my derived class. Then I drag the outlet from the table to the files owner and hook it up to an outlet variable in my main view, which is of the same type as my derived class.

How do I also set up the datasource and delegate so that they belong to the derived class?

I've got two table views on my main viewcontroller, and one of them uses that controller itself which works fine. The delegate and datasource is the file owner of the view controller.

But my other table view will be for different data, so I want it to use the datasource and delegate which is implemented on my derived tableview.

+1  A: 

When you click on the UITableView-derived object are you not able to see the delegate and datasource members under the Table View Connections pane of the Inspector window? It should be as simple as dragging a connection from each to file's owner, or whatever object you want to make delegate/datasource. I've seen them go away when all you do is change the class type of an object, but if you write headers and make sure your class says that it is derived from UITableView then return to IB I believe you will see them again.

(apparently IB2 used to handle this the way you expected - in IB3 it is best to derive in Xcode first, then use the derived class in IB)

Adam Eberbach
I guess I'm not sure what to drag where for my derived class table. I've added a bit more info to the end of my question.
justinhj
ah, I see, I can drag the delegate and datasource outlets to the table itself on the view
justinhj
not sure that's working, i get 2010-06-01 21:31:20.048 Timers1[11391:207] events loaded 502010-06-01 21:31:20.050 Timers1[11391:207] *** -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39329402010-06-01 21:31:20.051 Timers1[11391:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x3932940'
justinhj
hmm I think this is a duplicate of http://stackoverflow.com/questions/254354/uitableview-issue-when-using-separate-delegate-datasource
justinhj