A object remove from CCArray, is become disable.

A object remove from CCArray, is become disable.
0

#1

response = dynamic_cast<Response*>(s_responseQueue->objectAtIndex(0));
LoginResponse* tmpRsp = dynamic_cast<LoginResponse*>(response);
if (tmpRsp) {
ilog(“NetClient::dispatchResponseCallbacks --> before remove, success:%d”,tmpRsp->getSuccess()->getValue());// normal print
}
s_responseQueue->removeObjectAtIndex(0);
if (tmpRsp) {
ilog(“NetClient::dispatchResponseCallbacks --> after remove, success:%d”,tmpRsp->getSuccess()->getValue());// can’t print
}

#######
an aoturelease object,remove from CCArray, will release “right away(立即)”。
why remove from CCArray,it is disable?


#2

CCArray will mange reference count for you. I will add reference count when adding an element, and minus reference count when removing an element. It works like this just to make reference count correctly.

You should retain it if you want to use it after it is removed from an array. Each object lifecycle is managed by reference count.