2

Xcode 3.2.5, iOS 4.2 (Simulator), Cocos2D 0.99.5

Following this tutorial comes with a wonderful crash, as seen below.

I haven't found a single (directly) relevant thing through Google on any site. The closest I got was something else on this site with the same error, but a completely different reason. (I assume so, anyway. But then, given that 0.99.5 comes with two Analyzer results, it could just be a bad release…)

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x013cbbe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x015205c2 objc_exception_throw + 47
    2   CoreFoundation                      0x0133bb09 +[NSInvocation invocationWithMethodSignature:] + 553
    3   FirstGame                           0x0005ddd4 -[CCMenuItem initWithTarget:selector:] + 308
    4   FirstGame                           0x0005e528 -[CCMenuItemLabel initWithLabel:target:selector:] + 104
    5   FirstGame                           0x0005fb1d -[CCMenuItemFont initFromString:target:selector:] + 365
    6   FirstGame                           0x0005f8db +[CCMenuItemFont itemFromString:target:selector:] + 123
    7   FirstGame                           0x00003457 -[HelloWorld init] + 231
    8   FirstGame                           0x00063db1 +[CCNode node] + 81
    9   FirstGame                           0x0000332d +[HelloWorld scene] + 93
    10  FirstGame                           0x00002dbc -[FirstGameAppDelegate applicationDidFinishLaunching:] + 1212
    11  UIKit                               0x0085a253 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1252
    12  UIKit                               0x0085c55e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    13  UIKit                               0x00866db2 -[UIApplication handleEvent:withNewEvent:] + 1533
    14  UIKit                               0x0085f202 -[UIApplication sendEvent:] + 71
    15  UIKit                               0x00864732 _UIApplicationHandleEvent + 7576
    16  GraphicsServices                    0x02973a36 PurpleEventCallback + 1550
    17  CoreFoundation                      0x013ad064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    18  CoreFoundation                      0x0130d6f7 __CFRunLoopDoSource1 + 215
    19  CoreFoundation                      0x0130a983 __CFRunLoopRun + 979
    20  CoreFoundation                      0x0130a240 CFRunLoopRunSpecific + 208
    21  CoreFoundation                      0x0130a161 CFRunLoopRunInMode + 97
    22  UIKit                               0x0085bfa8 -[UIApplication _run] + 636
    23  UIKit                               0x0086842e UIApplicationMain + 1160
    24  FirstGame                           0x000028a4 main + 100
    25  FirstGame                           0x00002835 start + 53
)

I can't come up with anything. Maybe someone else has seen this before?

4 Answers 4

7

I had the same error due to my poor knowledge of selectors in Objective-C. I initially implemented the goToGameplay method with the signature:

-(void)goToGameplay;

instead i had to use:

-(void)goToGameplay:(id)sender;

This works with the call:

@selector(goToGameplay:)

Hope i helps.

1
  • 1
    I had a very similar issue and just adding the '(id)sender' to my selected function declaration corrected it even though I didn't even use that argument.
    – Sup3rpanda
    Jun 30, 2011 at 5:29
6

Specifically, it looks like this call?

CCMenuItem *Play = [CCMenuItemFont itemFromString:@"PLAY" target:self selector:@selector(goToGameplay:)];

Have you implemented goToGameplay: on your HelloWorld class?

The way the tutorial is written, you don't write the method until later in the tutorial. Thus, if you run the tutorial in the middle and try to hit that menu item, it will crash as described above.

2
  • That looks like the problem. I made the assumption that, at the clearly defined end of a part of a tutorial, the app should launch. ... No, that's not right. The end of Part 1 of that tutorial is the launching of a super-basic Cocos2D app. I'll continue anyway and see if and when it does launch. ... ... ... Yeah, I'll read every response next time. Marek, two down, caught the problem. I can't imagine how I missed it. I had '- (void)play:(id)sender {' instead of '- (void)goToGameplay:(id)sender {'. Well, that solves that problem.
    – Thromordyn
    Dec 20, 2010 at 15:10
  • Well, Marek's post was two down when I added that comment... Ah, whatever.
    – Thromordyn
    Dec 20, 2010 at 16:27
0

It looks like the selector you've passed to +[CCMenuItemFont itemFromString:target:selector:] is not implemented on your target object. Trying to look up the selector would result in a nil method signature, which would cause the error seen there.

0

I had the same problem. My issue was in the PauseScene.m file creating the menu items for resume and quit. In my case one of the names in the @selector part of CCMenuItem did not match the method name used later. Specifically, for me I used @selector(GotoMainMenu) but used GoToMainMenu for the method...the difference was "To" vs "to". To check, put an NSLog at the top of the init in the PauseScene.m file. If you see the message, the problem is somewhere here. If not, it's probably earlier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.