In Objective-c I have this:
SomeObject *values[3][3];
when deallocating, as in C++ should I release element by element?
Or if I do:
[values release];
is ok?
In Objective-c I have this:
SomeObject *values[3][3];
when deallocating, as in C++ should I release element by element?
Or if I do:
[values release];
is ok?
release
only applies to Objective-C objects. A C style array (like you have there) is just some stack memory.
In your case, it looks like you're using it to store 3x3=9 Objective-C objects in it. If you want to release them all, you need to do it element by element. The C++ analogy doesn't hold in this case because the array itself isn't an Objective-C object.
(If you were holding stuff in an NSMutableArray, the answer would be different. You should look into that by the way.)
It is an array of pointers. Just values
points to first object, so [values release]
will release only first object.
You have to release each object in array.