I am getting up to speed on using ARC for my iOS app development. Occasionally a plain ole c-array of plain old c-structs is all I need to get the job done. Prior to ARC I would just add free()
to my dealloc
method. With ARC there is nolonger any need for dealloc
. Is there an ARC directive I can add to tell the compiler to handle free-ing my c-array(s)?
Per Tom's answer here is the dealloc method
// EIVertex
struct EIVertex {
GLKVector3 p;
GLKVector3 n;
GLKVector3 barycentric;
GLKVector2 st;
};
typedef struct EIVertex EIVertex;
// ivar declaration
EIVertex *_vertices;
// malloc an array of EIVertex
_vertices = (EIVertex *)malloc([_triangles count] * sizeof(EIVertex));
// Note lack of [super dealloc]
- (void)dealloc{
// ARC will not handle mem. management for plain ole c arrays.
free(_vertices);
}
You can still overload dealloc. The only thing is you can not explicitly call it. So write dealloc as you used to, but dont call [super dealloc]
in it.