2013-10-27 96 views
1

我正在嘗試ARC啓用項目,並且在爲ARC選擇文件時遇到一些問題。將Cocos2d代碼轉換爲ARC問題

在球類,下面的行,

ballBody->SetUserData(self); 

給出了錯誤,

Cannot initialize a parameter of type 'void *' with an Ivalue of type 'Ball *const__strong' 

在Enemy.mm類,下面的行,

enemyBody->SetUserData(enemySprite); 

給出錯誤,

Cannot initialize a parameter of type 'void *' with an Ivalue of type 'CCPhysicsSprite*__strong' 

在Enemy.h我已經定義了上面:

b2Body* enemyBody; 
CCPhysicsSprite* enemySprite; (in Enemy.m) 

我該如何解決這些問題?

回答

2

橋鑄造:

ballBody->SetUserData((__bridge void*)self); 
enemyBody->SetUserData((__bridge void*)enemySprite); 

和反向:

CCPhysicsSprite* enemySprite = (__bridge CCPhysicsSprite*)enemyBody->GetUserData();