views:

881

answers:

1

I have seen something here[1] that states that I can remove these errors in xcode 3 by changing a method like -(IBAction) shakeShakeShake to -(IBAction) shakeShakeShake (id) sender

I am using iphone sdk 3.0 and xcode 3.2.1 on snow leopard

My errors are:

Classes/MainViewController.m:156: warning: 'MainViewController' may not respond to '-shakeShakeShake'

/Users/temp/Desktop/src/Count Down Timer (Utility App)/Classes/MainViewController.m:156:0 /Users/temp/Desktop/src/Count Down Timer (Utility App)/Classes/MainViewController.m:156: warning: (Messages without a matching method signature

Classes/MainViewController.m: At top level:

Classes/MainViewController.m:467: warning: incomplete implementation of class 'MainViewController'

Classes/MainViewController.m:467: warning: method definition for '-pickerView:' not found

Classes/MainViewController.m:467: warning: method definition for '-shakeShakeShake:' not found

----- (sorry about the long error msgs, I tried to cut them down by removing compiler and path info) ---

I have tried adding things like

-(void)shakeShakeShake: (id) sender ;

as a prototype to the .h file and to the .m file

- (IBAction) shakeShakeShake: (id) sender {

dimView.alpha = 0.0f ; }

Making these changes will make the warning go away, but when I run my program and execute this function, it will exit to the Springboard with a console message:

[MainViewController shakeShakeShake]: unrecognized selector sent to instance 0x1213a20 2009-12-21 02:19:17.389 Count Down Timer (Utility App)[43704:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[MainViewController shakeShakeShake]: unrecognized selector sent to instance 0x1213a20'

When I change the function back to - (IBAction) shakeShakeShake { (even if I leave the prototype style in with : (id) sender), the program (a simple utility timer) runs fine and gives no errors to the console.

I can't seem to figure out what I'm doing wrong, but I was always taught to remove warnings if possible as they may note problems that only surface later and are hard to find.

Can anyone point me in the right direction here? thanks very much for your patience, I'm still new at this! ;-)

Thanks Piesia

BTW, shakeShakeShake is called here:

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {

if (event.type == UIEventSubtypeMotionShake) { //Your code here [ self shakeShakeShake ] ; } }

---- error msgs follow

Classes/FlipsideViewController.m:401: warning: incomplete implementation of class 'FlipsideViewController' Classes/FlipsideViewController.m:401: warning: method definition for '-pickerView:' not found Classes/FlipsideViewController.m:401: warning: method definition for '-shakeShakeShake' not found

A: 

It looks like I need to give the sender parameter explicitly as follows in the message call:

//instance method declaration - (IBAction) shakeShakeShake: (id) sender ;

  • (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) {

// message -- method signature + parameter information [ self shakeShakeShake: self ] ;

}

} // ^-- needed for shake

//instance method definition - (IBAction) shakeShakeShake: (id) sender {

    // make window clear
dimView.alpha = 0.0f ;  // always undim screen in shake as a failsafe

}

When I do it like this, the warnings go away and the app seems to work. Thanks for your time. Piesia

Piesia
I removed the method declaration of shakeShakeShake from FlipsideViewController.h as it wasn't used in this class.The missing pickerView method was because my method declaration was missing a parameter! Regards, Piesia
Piesia