0
我有一個單身人士,產生長,lats。我可以登錄他們,但希望能夠得到他們。我究竟做錯了什麼?從單身人士獲取字符串
singleton.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,經緯度串給定的值 - (ID)初始化
- (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];
}
codethatcallsthem.m
NSString *formatted3 = [[ClassLocationManager sharedSingleton] longt];
NSString *formatted4 = [[ClassLocationManager sharedSingleton] lat];
非常感謝。
選項2返回在(id)init中設置的值,但不返回(void)locationManager中生成的值。 –
lat = [NSString stringWithFormat:@「%d°%d'%1.4f \」「,degrees,minutes,seconds]; => self.lat = ... longt相同 –
這就是我所做的 - 這是一個時間問題 - 我需要解決如何延遲這個過程,直到它有結果 - 非常感謝。 –