NSUInteger numPoints = [[self locationFake] count];
CLLocationCoordinate2D *pointsPtr = malloc(numPoints * sizeof(CLLocationCoordinate2D));
for(int counter=0; counter<numPoints; counter++) {
pointsPtr[counter] = [[[self locationFake] objectAtIndex:counter] coordinate];
}
// (1)
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:pointsPtr count:numPoints];..。
free(pointsPtr);
pointsPtr = NULL;在我创建了MKPolyline对象(1)之后,我可以释放points使用的内存吗,或者MKPolyline在它创建后仍然引用该内存,我不应该释放points,直到我完全使用完MKPolyline对象?
发布于 2011-01-25 02:23:10
据我所知,你可以释放内存。我使用了一个堆栈分配的固定大小的缓冲区,它工作得很好,这意味着polyline必须将这些坐标复制到某个地方。
https://stackoverflow.com/questions/4785216
复制相似问题