繼承人我的問題我想創建一個回調函數爲iphone的cocos2d中的動作序列,但我不斷收到錯誤的訪問錯誤。CCCallFunc和ARC
這裏創建我回電話
id myCallFunc = [CCCallFuncND actionWithTarget:self.delegate selector:@selector(playerAttack:data:) data:(__bridge void *)([[PlayerAttackPacket alloc] initWithPlayer:@"" attackChoice: [NSNumber numberWithInt: item.tag]]) ]; // to call our method
這裏是函數多數民衆贊成叫回來,並轉換數據時,編譯說壞的訪問。
-(void) playerAttack:(id)sender data:(void *)data
{
PlayerAttackPacket* packet = (__bridge PlayerAttackPacket*)data;
BattleModel *model = [BattleModel sharedInstance];
int choice = packet.attackChoice.intValue;
NSString * players = packet.player;
}
球員包:
@interface PlayerAttackPacket : NSObject {
NSString * player;
NSNumber * attackChoice;
}
@property (nonatomic, retain) NSString * player;
@property (nonatomic, retain) NSNumber * attackChoice;
-(id) initWithPlayer: (NSString*)_player attackChoice: (NSNumber*)choice;
@end
@implementation PlayerAttackPacket
@synthesize player,attackChoice;
-(id) initWithPlayer: (NSString*)_player attackChoice: (NSNumber*)choice
{
if((self=[super init]))
{
self.player = _player;
self.attackChoice = choice;
}
return self;
}
@end
誰能告訴我什麼,我做錯了什麼? =(。我的感覺是它與ARC有關,但我不確定。
你從哪裏得到錯誤的訪問異常?你在哪裏運行CCCallFuncND? –
首次訪問「數據」時,playerAttack發生訪問不良(請參閱上文)。 CCCallFunND在CCSequence中並在其結尾被調用。 – AwDogsGo2Heaven