How to extract delegates from ViewController class?
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 insi开发者_高级运维de 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?
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.
精彩评论