tags:

views:

61

answers:

2

I think I have a conceptual misunderstanding and would appreciate an explanation.

Within a class, I had the same block of code repeating 3 times (and working perfectly) but to try to make things more "efficient" I took it out and made a method within the class as follows:

- (void)dateUP {
NSLog(@"dateUp");
[UIView beginAnimations:@"datePicker" context:nil];
[UIView setAnimationDuration:0.5];

datePicker.transform = CGAffineTransformMakeTranslation(0,-310);
[UIView commitAnimations];
}

and then where the code originally was, I put:

[self dateUp];

and I put the following in my .h:

-(void)dateUp;

I build and get this warning:

Line Location DetailPopUpView.m:165: warning: method definition for '-dateUp' 
not found

and a crash with this in the console (and btw, the NSLog statement doesn't appear in the console):

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '*** -[DetailPopUpView dateUp:]: unrecognized selector sent to instance
0x3d33ef0'

Any help appreciated. One thing that I notice is that the console message has dateUp: (with a colon) as if a parameter is expected. So whereas the simplest solution is just to put the code back, repeating it 3x, I'd like to know what I'm doing wrong.

Thanks.

+4  A: 

Your method is:

- (void)dateUP { ... }

Your header declaration includes:

-(void)dateUp;

You might have a spelling error.

Alex Reynolds
Thanks Alex. This is embarrassing. Quite right. I need more sleep.
Matt Winters
Happens to all of us!
Alex Reynolds
Too many times to admit to!
Frank Shearar
+2  A: 

Looks like you have cases where your selectors (method names) aren't matching. dateUP is different from dateUp which is much different from dateUp:

This should work fine:

- (void)dateUp
{
    NSLog(@"dateUp");
    [UIView beginAnimations:@"datePicker" context:nil];
    [UIView setAnimationDuration:0.5];
    datePicker.transform = CGAffineTransformMakeTranslation(0,-310);
    [UIView commitAnimations];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self dateUp];
}
rpetrich