iPhone: How to store a location (CLLocationCoordinate2D) inside a class w/o leaking memory?
Posted
by Henry
on Stack Overflow
See other posts from Stack Overflow
or by Henry
Published on 2010-03-08T21:12:38Z
Indexed on
2010/03/08
21:21 UTC
Read the original article
Hit count: 662
I am creating a library which contains an API for setting the current location based off some value collected by the GPS. I want to store this location in my class and later, change the behavior of my library if it is set.
What I had in mind was:
@interface myLib
{
@property (nonatomic, retain) CLLocationCoordinate2D *location;
}
@implementation myLib
{
@synthesize location = _location;
- (void)setLocation:(CLLocationCoordinate2D *)loc {
location = loc;
}
- (void)someFunc {
if (location != nil) ...
}
}
However, retain isn't a valid property for a CLLocationCoordinate2D object.
So, what is the proper way to save CLLocationCoordinate2D for later use w/o wasting memory?
Thanks in advance!
© Stack Overflow or respective owner