1
votes

I am trying to save the user's location but the code below is returning an error. Instead of creating a new key "currentLocation" it's returning an error and creating a key "hello." Why would that be?

[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
            if (!error) {
                NSLog(@"User is currently at %f, %f", geoPoint.latitude, geoPoint.longitude);
                [[PFUser currentUser] setObject:geoPoint forKey:@"currentLocation"];
                [[PFUser currentUser] saveInBackground];
            }
            else {
                [[PFUser currentUser] setObject:hello forKey:@"hello"];
            }
        }];
1
Have you properly asked for access to Location services for your app? - Timothy Walters
Could you please log the error in your else { NSLog(@"%@", error); ...}. - Yuchen
@TimothyWalters I just have to include it in the plist, right? If so, I did do that. - user3783615
@YuchenZhong The error is: The operation couldn’t be completed. (kCLErrorDomain error 0.) - user3783615

1 Answers

0
votes

Figured it out! I had to go to Product -> Scheme -> Edit Scheme -> Options and add a Default Location.