iPhone: How to store a location (CLLocationCoordinate2D) inside a class w/o leaking memory?
- by Henry
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!