我有一个单例,可以生成长的,lats。我可以记录它们,但希望能够得到它们。我究竟做错了什么?
单例.h
@interface ClassLocationManager : NSObject <CLLocationManagerDelegate> {
NSString *lat;
NSString *longt;
}
@property (nonatomic, strong) CLLocationManager* locationManager;
@property (nonatomic, retain) NSString *lat;
@property (nonatomic, retain) NSString *longt;
+ (ClassLocationManager*) sharedSingleton;
singleton.m - longt, lat 字符串在 -(id)init 中给出值
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees, minutes, seconds];
NSLog(@" Current Latitude : %@",lat);
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees, minutes, seconds];
NSLog(@" Current Longitude : %@",longt);
[manager stopUpdatingLocation];
}
调用它们的代码.m
NSString *formatted3 = [[ClassLocationManager sharedSingleton] longt];
NSString *formatted4 = [[ClassLocationManager sharedSingleton] lat];
非常感谢。