views:

91

answers:

1

Hi

I have the problem that my view controller class has too many delegates and starts to get big. I want to write the delegates in separate classes to keep the view controller class small. For delegates that are programmatically created (like UIAlertViewDelegate) I could do it easily.

The problem is in the delegates assigned in Interface Builder. How can I tell the IB to assign, for example, another class as the UITableViewDelegate or UITableViewDataSource? Or how to choose another IBAction method for a Touch UP inside Event on a button?

One solution would be to delete the connections from IB and write them programmatically at ViewDidLoad, but since I have a lot of ViewControllers, this would take a long time.

any other ideas?

A: 

You drag an NSObject from the Library in IB and change its class in the Inspector. This way, you create an instance of your delegate class. You can then connect the delegate outlet of your UITableView to the newly created object in IB.

Diederik Hoogenboom
thanks that gives me a start.What I don't understand is when an instance of my delegate will be created. Actually, I got an EXC_BAD_ACCESS when the delegate methods should be called and I suppose that the delegate object could not be found at run time.
adranale
well.. it turned out that I should make an outlet from the viewController to my delegate and a delegate object will be created at runtime (I suppose when the View Controller will be loaded).
adranale