I have a custom object which handles some operations with views. Basically it initializes a UIView with a nib file. But I want my viewcontroller to be responsible to handle IBActions. So I setted my viewcontroller to be the file owner and connected IBActions.
In my custom object I load nib file like this:
self.nibView = [[[NSBundle mainBundle] loadNibNamed:@"nibName" owner:delegate options:optionsDict] lastObject];
I setted delegate which is my UIViewController(kind of strange) to be the owner. So I was expecting my viewcontroller to handle IBActions but it did not. My custom object tried to respons the action and of course application crashed because of not responding to selector. How can I achieve that ?
Edit:
View Controller
Custom Object
Nib File
The delegate is a protocol, the owner should be an object.
If your view controller conforms to the delegate protocol, you should set
owner:self
and ensure that the delegate property of the view is set to be your view controller. This can be done in IB using the IBOutlet, or in code by something like:self.nibView.delegate = self