首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MKPolyline和内存?

MKPolyline和内存?
EN

Stack Overflow用户
提问于 2011-01-25 01:46:54
回答 1查看 431关注 0票数 1
代码语言:javascript
复制
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];

..。

代码语言:javascript
复制
free(pointsPtr);
pointsPtr = NULL;

在我创建了MKPolyline对象(1)之后,我可以释放points使用的内存吗,或者MKPolyline在它创建后仍然引用该内存,我不应该释放points,直到我完全使用完MKPolyline对象?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-25 02:23:10

据我所知,你可以释放内存。我使用了一个堆栈分配的固定大小的缓冲区,它工作得很好,这意味着polyline必须将这些坐标复制到某个地方。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4785216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档