Touch Dispatcher register

Touch Dispatcher register
0.0 0


i have started using cocos2d-x in iphone. i have create a class which inherit from cclayer , now when i try to register it with touch dispatcher it got crash.

in .h file.
class BasePage : public cocos2d::CCLayer

and .m file

CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, INT_MIN + 1, true);

and i got crash in ccobject.m file

void CCObject::retain(void)
CCAssert(m_uReference > 0, “reference count should greater than 0”);[here is crash]


Can anyone please give me some solution ?

Thank you in advance


Can you please show your code for BasePage (.h and .m) and the code of function where you create BasePage. The possible reason for this error is you trying to use an object which is already released.