unexpected invoke copyWithZone c++ cocos2d

392 Views Asked by At

I have some trouble.

I made some interface (abstract class in c++). Implemented it in my class (derived from CCObject too). In third class I try to invoke method of interface and got SIGABORT. Here the code

 //interface class


class CallBackInterface
 {
 public:
       virtual void SomeMethod() = 0;
 };

 //my class that implement the interface 
 class MyClass : public CallBackInterface, public CCObject
 {
 public:
       void SomeMethod(){/*some realization*/}; 
 };

 //class that invoke the SomeMethod


class CallBacker()
 {
 public:
       CallBackInterface* callBackObject;
 };

 //main code


CallBacker* callBacker = new CallBacker();
 MyClass* myClass = new MyClass();
 callBacker->callBackObject = myClass;

/*
this string generate unexpected invoke of copyWithZone method CCObject's class
with SIGABORT. */

callBacker->callBackObject->SomeMethod();

/*
In debugger mode I see that SomeMethod don't invoke (debugger don't  go                                into it). Here the copyWithZone*/

CCObject* CCCopying::copyWithZone(CCZone *pZone)
    {
        CC_UNUSED_PARAM(pZone);
        CCAssert(0, "not implement"); <<- here is SIGABORT
        return 0;
    }

The copyWithZone invokation crashes my app

1

There are 1 best solutions below

0
On
class CallBackInterface : public CCObject
{
public:
     virtual void SomeMethod() = 0;
};

class MyClass : public CallBackInterface
{
     void SomeMethod(){}
};

Try this! I met the same problem before.