Is it possible to connect delegate and dataSource of CustomViews in interface builder?

ios, objective-c

Solution

You'll need to meet these conditions:

- The view's `Custom Class` should be set to your custom view's class name in Interface Builder (via the Identity Inspector). If your delegate or dataSource object is also a custom view, also make sure that that view's Custom Class is set

- The `@interface` for your custom class should decorate its delegate and dataSource properties with `IBOutlet`. For example, `@property (nonatomic, weak) IBOutlet id <SomeProtocol> delegate;`

- If you declared protocol(s) for your delegate or dataSource, the target object that you want to use as the delegate or dataSource should be declared as implementing that protocol

Problem

In Interface builder, If I right click on a tableView, I get option of delegate and dataSource outlets which at times we connect to the file's owner which is in most cases the View Controller which implements these protocol, How can I get a similar option for my custom view which has a delegate and a datasource property ?

Original source