I'm trying to set the delegate for a scroll view using Interface Builder.
If I have code like this:
MyScrollViewDelegate * delegate = [[MyScrollViewDelegate alloc] init];
[scrollView setDelegate:delegate];
in viewDidLoad, everything works perfectly.
If I open Interface Builder, add an NSObject and set the class to MyScrollViewDelegate, then link the scrollView's delegate to my instance of MyScrollViewDelegate and inspect [scrollView delegate] inside viewDidLoad, it looks like an instance of MyScrollViewDelegate, and I can interact with it, set proprerties etc, looks good.
However, when I scroll inside the scroll view I get an NSInvalidArgumentException:
*** -[NSCFArray scrollViewDidScroll:]: unrecognized selector sent to instance 0x3d319a0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray scrollViewDidScroll:]: unrecognized selector sent to instance 0x3d319a0'
So, questions:
- What is the difference between setting the delegate in Interface Builder vs using setDelegate:?
- Why is "[NSCFArray scrollViewDidScroll:]" in the console, not, [MyScrollViewDelegate scrollViewDidScroll:]?
- What could I be doing wrong?