Hi
I'm getting a warning when I set the delegate for UIImagePickerController. It's because UIImagePickerController and its parent UINavigationController both have delegates that can be used. The code works fine but just wondering how to handle delegates and inheritance properly and lose the warning.
So basically I've created my own MyImagePickerController which is subclass UIImagePickerController. UIImagePickerController is a sub class of UINavigationController. so the inheritance tree is
UINavigationController > UIImagePickerController > MyImagePickerController
MyImagePickerController is also the delegate for UIImagePickerController. So I add to my @interface.
@interface MyImagePickerController : UIImagePickerController <UIImagePickerControllerDelegate>...
Then I set MyImagePickerController to be the delegate to itself in loadView
- (void) loadView
{
...
self.delegate = self;
...
} And I implement the UIImagePickerControllerDelegate delegate methods and it all works.
But I get a warning
warning: class 'MyImagePickerController' does not implement the 'UINavigationControllerDelegate' protocol
The problem is that both parent classes have their own Delegates
UINavigationController > UIImagePickerController > MyImagePickerController
UINavigationControllerDelegate > UIImagePickerControllerDelegate > MyImagePickerController
And in the definition for UIImagePickerController the delegate method can take either UINavigationControllerDelegate or UIImagePickerControllerDelegate
@interface UIImagePickerController : UINavigationController <NSCoding> {
@property(nonatomic,assign) id <UINavigationControllerDelegate, UIImagePickerControllerDelegate> delegate;
The app works, the UIImagePickerControllerDelegate methods in MyImagePickerController are being called but is there a proper way to set the delegate so someone reading the code knows we're trying to implement UIImagePickerControllerDelegate methods and for a newbie to clear the warning.
And what happens if you want to implement both UIImagePickerControllerDelegate and UINavigationControllerDelegate methods in the UIImagePickerControllerDelegate? How would you set the single delegate in Obj-C? Cheers