我一直在試圖調用下面的函數。似乎只要在函數playNote我試圖訪問我作爲參數傳遞的對象( myNum)它總是崩潰。我很新,我可能不明白如何通過CCCallFuncND傳遞參數。所有意見都表示讚賞。Objective C - CCCallFuncND正確傳遞參數
這是傳遞參數myNum的電話:
id action2 = [CCCallFuncND actionWithTarget:self selector:@selector(playNote:data:) data:(NSNumber *)myNum];
這是整個街區:
- (void)muteAndPlayNote:(NSInteger)noteValue :(CCLayer*)currentLayer
{
myNum = [NSNumber numberWithInteger:noteValue];
NSLog(@"Test the number: %d", [myNum integerValue]);
id action1 = [CCCallFunc actionWithTarget:self selector:@selector(muteAudioInput)];
id action2 = [CCCallFuncND actionWithTarget:self selector:@selector(playNote:data:) data:(NSNumber *)myNum];
id action3 = [CCDelayTime actionWithDuration:3];
id action4 = [CCCallFunc actionWithTarget:self selector:@selector(unmuteAudioInput)];
[currentLayer runAction: [CCSequence actions:action1, action2, action3, action4, nil]];
}
的NSLog永遠不會顯示任何崩潰在這條線。
- (void) playNote:(id)sender data:(NSNumber *)MIDInoteValue
{
NSLog(@"Test number 2: %d", [MIDInoteValue integerValue]);
int myInt = [MIDInoteValue floatValue];
[PdBase sendFloat: 55 toReceiver:@"midinote"];
[PdBase sendBangToReceiver:@"trigger"];
}
這是罪魁禍首!它解決了。謝謝 – enamodeka