可可 – 在NSMutableArray中存储CLLocationCoordinates2D

可可 – 在NSMutableArray中存储CLLocationCoordinates2D,第1张

概述经过一番搜索,我得到以下解决方案: reference。 CLLocationCoordinate2D* new_coordinate = malloc(sizeof(CLLocationCoordinate2D));new_coordinate->latitude = latitude;new_coordinate->longitude = longitude;[points addObj 经过一番搜索,我得到以下解决方案:
reference。

CLLocationCoordinate2D* new_coordinate = malloc(sizeof(CLLocationCoordinate2D));new_coordinate->latitude = latitude;new_coordinate->longitude = longitude;[points addobject:[NSData dataWithBytes:(voID *)new_coordinatelength:sizeof(CLLocationCoordinate2D)]];free(new_coordinate);

并访问它:

CLLocationCoordinate2D* c = (CLLocationCoordinate2D*) [[points objectAtIndex:0] bytes];

不过有人声称这里有内存泄漏?任何人都可以建议我在哪里泄漏和如何解决它。另外还有一种在NSMutableArray中存储CLLocationCoordinate2D列表的更好方法?请给出示例代码,因为我是一个Objective C新手。

解决方法 没有泄漏,只是浪费堆内存。

你可以使用

CLLocationCoordinate2D new_coordinate;new_coordinate.latitude = latitude;new_coordinate.longitude = longitude;[points addobject:[NSData dataWithBytes:&new_coordinate length:sizeof(new_coordinate)]];
总结

以上是内存溢出为你收集整理的可可 – 在NSMutableArray中存储CLLocationCoordinates2D全部内容,希望文章能够帮你解决可可 – 在NSMutableArray中存储CLLocationCoordinates2D所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1035596.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存