, , MVC. . CLLocation .
@interface User {}
@property (nonatomic, retain) CLLocation *location;
@end
@implementation User
@synthesize location;
- (void)dealloc {
self.location = nil;
[super dealloc];
}
@end
. .
. CLLocationManager . , GPS, , , LBS.
- . .
. . /.
viewDidLoad .
- (void)viewDidLoad {
[self observeValueForKeyPath:@"location" ofObject:self.user change:0 context:NULL];
}
, , .
:
- CLLocationManager . , api , , . viewDidLoad locationManager.location API.
- Do not share materials with the application delegate. This will prevent code reuse. What if you reuse your views and the application delegate does not have a location manager?
if you need more code please ask.
source
share