I am trying to save a NSMutableArray to an array associated with the currently logged in user on my Parse User table but my array doesn't get saved. What am I doing wrong?
This method is called in viewDidLoad()
- (void)getSavedLocations {
if ([[PFUser currentUser]objectForKey:@"Latitude"] == NULL) {
self.latitudeArray = [[NSMutableArray alloc]init];
self.longitudeArray = [[NSMutableArray alloc]init];
}
else {
self.latitudeArray = [[PFUser currentUser]objectForKey:@"Latitude"];
self.longitudeArray = [[PFUser currentUser]objectForKey:@"Longitude"];
}
}
This method is adds objects to my arrays but the Parse arrays don't get updated with the new data.
- (IBAction)saveLocationPressed:(id)sender {
NSString *latString = [NSString stringWithFormat:@"%f", self.myLatitude];
NSString *longString = [NSString stringWithFormat:@"%f", self.myLongitude];
[self.latitudeArray addObject:latString];
[self.longitudeArray addObject:longString];
[[PFUser currentUser]setObject:self.latitudeArray forKey:@"Latitude"];
[[PFUser currentUser]setObject:self.longitudeArray forKey:@"Longitude"];
}