tags:

views:

29

answers:

1

I have in my Picker class:

- (id)initWithFrame:(CGRect)frame withSender:(id)sender withDate:(NSDate*)date {
    if ((self = [super initWithFrame:frame])) {

datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0 , 0, 0)];
datePicker.date = date;
[sender changeDate:self.datePicker];
datePicker.date = date;

}

And in the sender class:

- (void)changeDate:(id)sender {

//some code

}

Both the methods are also declared in the .h files.

But when i compile, even if everything is working well, xCode tells me :

no '-changeDate:' method found

referring to the line [sender changeDate:self.datePicker];

What can i do to make this disappear? Thanks!

+2  A: 

Because your sender have the type id, and for the type id, there is no method called (changeDate:). So, if you want to call the changeDate: method, you have to cast your sender, or you have to specify a specific class type.

(MySender *)mySender = (MySender *)sender;

or

- (id)initWithFrame:(CGRect)frame withSender:(MySender *)sender withDate:(NSDate*)date {
vodkhang
Thank you very much! (this was quite obvious! :-/ )
Abramodj