I made a very basic dictionary that just stores a username in it, and I also want to store dynamically generated latlngs in it as well. I can already get the current latlng, and am working on how to track the location and store the new latlngs, which updates based on either distance or time.
How would I go about storing multiple latitudes under the key ‘latitude’ and the same for longitude?
My dictionary with the username is here:
username = Textbox.text;
NSMutableDictionary *mydata = [[NSMutableDictionary alloc] init ];
[mydata setObject:username forKey:@"username"];
NSLog(@"%@", [mydata objectForKey:@"username"]);
My current location code is here:
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];
Any help would be greatly appreciated.
If you have two latitudes…
that you’d like to put in an array, first “wrap” them up as NSNumbers…
which will let you put them in an array…
which can be placed in your dictionary (under the key @”latitude” if you want)…
Though, you might want to associate several latitude arrays with different unique longitudes. If so, instead of using the string @”latitude” as the key, the longitude itself (if it’s an NSNumber) can be a perfectly good key.