doesNotRecognizeSelector exception
doesNotRecognizeSelector exception
- Subject: doesNotRecognizeSelector exception
- From: Jeffrey Walton <email@hidden>
- Date: Sat, 26 Mar 2011 21:39:38 -0400
Hi All,
I have a protocol and declarations as follows. respondsToSeletor
returns NO. If I ignore respondsToSeletor (and send the message), I
get an expeption.
// FilePicker.m - try both
BOOL responds = [delegate respondsToSelector:@selector(userSelectedFile:)];
BOOL responds = [delegate
respondsToSelector:@selector(userSelectedFile:fileSystemObject:suppliedContext:)];
Any ideas on my error(s)? I can't seem to locate it (or them) on my own.
Jeff
// FilePicker.h
@protocol FilePickerDelegate <NSObject>
@required
// Delegate method called when the user selects a file in the picker.
- (void) userSelectedFile:(FilePicker*)picker
fileSystemObject:(FileSystemObject*)fso
suppliedContext:(NSUInteger)context;
// Delegate method called when the user cancels the picker.
- (void) userSelectedCancel:(FilePicker*)picker
suppliedContext:(NSUInteger)context;
@end
@interface FilePicker : UIViewController
<UIPickerViewDelegate, UIPickerViewDataSource>
{
...
id<FilePickerDelegate> delegate;
NSUInteger context;
}
@property (assign, nonatomic) id delegate;
@property (assign, nonatomic) NSUInteger context;
...
// FilePicker.m
// Designated initializer
// pickerDelegate is the callback when the user selects 'Cancel' or
'Done'. The delegate is not retained.
// pickerContext is a user supplied context. Its is passed back to the
delegate (and unused by this class). The context is not retained.
- (id)initWithDelegate:(id<FilePickerDelegate>)pickerDelegate
withContext:(NSUInteger)pickerContext
{
if(![super init])
return nil;
self.delegate = pickerDelegate;
self.context = pickerContext;
return self;
}
// MyViewController.h
@interface MyViewController : UIViewController
<FilePickerDelegate>
{
...
}
// MyViewController.m
FilePicker* picker = [[FilePicker alloc] initWithDelegate:self withContext:0];
[self presentModalViewController:picker animated:YES];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden