Hi Im confusing how to release already aclloc class which dosen’t store pointer from the header file. After the loop I lost my pointer to classes since it has all same instance name.
for(i=0;i<20;i++){
MyClass *class = [[MyClass init]alloc];
class.count = i;
[classArray addObject:class];
[self addToScene:class];
}
I understand basic concept of memory alloc and retain but since I’m using cocos2d to programe, I’m not sure about the cause of the error is from Object-c or cocos2d. so I want to just make a clear idea about the dealing memory in object-c. help me:-)
Præ-scriptum: that alloc and init calls should be exchanged (allocate first, only then initialize).
You have to release them inside the loop – adding them to the array retains them.