私は以下のコードを持っています。cocos2d ccmenuitemは変数にアクセスできない、SIGABRTで終わる
ここでは、コンソールでの出力です:
2011-07-29 13:52:52.906 HelloWorld[1031:207] -[NSCFString shuffle]: unrecognized selector sent to instance 0x6833c90 2011-07-29 13:52:52.976 HelloWorld[1031:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString shuffle]: unrecognized selector sent to instance 0x6833c90'
私はドン」:事は、私が「SIGABRTは、プログラムが信号を受信した」と「SPIN」ccmenuitem、プログラムがクラッシュをクリックするたびにあります何が間違っているのかわかります。
ここに私のコードです。
`#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface GameScene : CCLayer {
NSMutableArray * answersArray; //holds all valid answers
NSMutableArray * lettersArray; //holds placement of letters to display
NSMutableArray * userAnswerArray; //holds user's answer to check and submit
NSString * THEWORD; //the word
}
+(id) scene;
....
- (void) spinWord;
- (void) playWord;
@end`
そして、この実装:
`
@implementation GameScene
+(id) scene { ... }
-(id) init
{
if((self=[super init])) {
...//everything is initialized
[self initImages]
...
}
}
- (void) initImages
{
....
CCMenuItem *menuItem1 = [CCMenuItemImage itemFromNormalImage:@"PLAYunselected.png" selectedImage:@"PLAYselected.png" target:nil selector:@selector(onPlayWord)];
CCMenuItem *menuItem2 = [CCMenuItemImage itemFromNormalImage:@"SPINunselected.png" selectedImage:@"SPINselected.png" target:self selector:@selector(spinWord)];
CCMenu *menu = [CCMenu menuWithItems:menuItem1, menuItem2, nil];
[menu alignItemsHorizontally];
menu.position = ccp(72, 198);
[self addChild:menu z:2];
}
- (void) spinWord{
//NSLog(@"%@",lettersArray); <---if I uncomment this line, I get an EXC_BAD_ACCESS message instead
[lettersArray shuffle]; // <--- this line causes the SIGABRT signal, even if it's initialized.
NSLog(@"%@",lettersArray);
...
}
@end `
が私を助けてください。これはメモリ管理の問題ですか?もしそうなら、私はそれをどのように修正するのですか?
ありがとうございました!
あなたはlettersArray –