我做了一個非常基本的字典,它只存儲一個用戶名,並且我也想在其中存儲動態生成的latlng。我已經可以獲得當前的經驗,並且正在研究如何跟蹤位置並存儲新的緯度,並根據距離或時間進行更新。如何將動態位置數據加載到字典對象/數組中?
我將如何去關於'緯度'和經度相同的存儲多個緯度?
我的用戶名字典是在這裏:
username = Textbox.text;
NSMutableDictionary *mydata = [[NSMutableDictionary alloc] init ];
[mydata setObject:username forKey:@"username"];
NSLog(@"%@", [mydata objectForKey:@"username"]);
我目前的位置代碼是在這裏:
locationManager =[[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = 100.0f;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];
任何幫助將不勝感激。
將它們存儲爲字符串將工作,但使用NSNumber編碼/解碼爲浮點數據類型更容易。 – amleszk 2012-03-23 00:41:32