![](/img/trans.png)
[英]+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil (Cocos2d)
[英]'+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil' (Cocos2D)
Xcode 3.2.5,iOS 4.2(模擬器),Cocos2D 0.99.5
在本教程之后會出現一個精彩的崩潰,如下所示。
我沒有通過谷歌在任何網站上找到一個(直接)相關的東西。 我得到的最接近的是這個網站上的其他東西有相同的錯誤,但完全不同的原因。 (無論如何,我假設如此。但是,鑒於0.99.5帶有兩個Analyzer結果,它可能只是一個糟糕的版本...)
*** 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
)
我無法想出任何東西。 也許其他人之前見過這個?
由於我對Objective-C中選擇器的了解不足,我遇到了同樣的錯誤。 我最初使用簽名實現了goToGameplay方法:
-(void)goToGameplay;
相反,我不得不使用:
-(void)goToGameplay:(id)sender;
這適用於電話:
@selector(goToGameplay:)
希望我有所幫助。
具體來說,它看起來像這個電話?
CCMenuItem *Play = [CCMenuItemFont itemFromString:@"PLAY" target:self selector:@selector(goToGameplay:)];
你在HelloWorld
課上實現了goToGameplay:
編寫教程的方式,直到本教程后面才編寫該方法。 因此,如果您在中間運行教程並嘗試點擊該菜單項,它將如上所述崩潰。
看起來你傳遞給+[CCMenuItemFont itemFromString:target:selector:]
沒有在你的目標對象上實現。 試圖查找選擇器將導致nil
方法簽名,這將導致在那里看到錯誤。
我有同樣的問題。 我的問題是在PauseScene.m文件中創建了resume和quit的菜單項。 在我的例子中,CCMenuItem的@selector部分中的一個名稱與稍后使用的方法名稱不匹配。 具體來說,對我來說,我使用@selector(GotoMainMenu),但使用GoToMainMenu作為方法......差異是“To”vs“to”。 要檢查,請將NSLog放在PauseScene.m文件中init的頂部。 如果您看到該消息,則問題出在此處。 如果沒有,它可能更早。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.