自动参考计数(ARC).可以弧形释放普通的ole c-array



我正在加快使用ARC进行iOS应用程序开发。有时,我需要完成工作的普通旧c-阵列才能完成这项工作。在ARC之前,我只会将free()添加到我的dealloc方法中。使用ARC,有任何需要dealloc的人。我可以添加一个弧线指令来告诉编译器以处理我的C阵列的自由吗?

每个汤姆的回答是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);
}

您仍然可以超载DealLoc。唯一的事情是您无法明确称呼它。因此,按照您的过去写Dealloc,但不要在其中拨打[super dealloc]

最新更新