iOSアプリの開発にARCを使用することに慣れています。時折、私が仕事を成し遂げるために必要なのは、単純な古いc-structの単純なolec-arrayだけです。ARCの前はfree()
、dealloc
メソッドに追加するだけでした。ARCを使用すると、の必要がなくなりますdealloc
。コンパイラにc-arrayの解放を処理するように指示するために追加できるARCディレクティブはありますか?
ここでのトムの答えによると、deallocメソッドです
// 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);
}