IMustCode
IMustCode

Reputation: 109

Converting Cocos2d code to ARC issues

I am trying to ARC enable a project and I am having a few issues when selecting files for ARC.

In the Ball class, the following line,

ballBody->SetUserData(self);

gives the error,

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

In the Enemy.mm class, the following line,

enemyBody->SetUserData(enemySprite);

gives the error,

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

In Enemy.h I have defined the above as:

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

How can I solve these issues?

Upvotes: 1

Views: 64

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

Bridge casting:

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

and the reverse:

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

Upvotes: 2

Related Questions