Not calling the didEnterRegion and didExitRegion in regionMonitoring - ios

I set some constant lat and long,Wherever i go it showing inside when i launch my app.stand end exit methods are never called.tried many time getting the same problem.
Here is my code Please help,Thanks in advance
- (void)viewDidLoad
{
[super viewDidLoad];
[self initializeLocationServices];
}
-(void)initializeLocationServices
{
NSLog(#"Started location services");
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.distanceFilter = kCLDistanceFilterNone;
_locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
_locationManager.pausesLocationUpdatesAutomatically = NO;
[_locationManager startUpdatingLocation]; // to show authorisation popup
}
-(CLCircularRegion*)createRegion
{
// Test coordinates
CLLocationDegrees latitude = 12.908768;
CLLocationDegrees longitude = 77.652061;
CLLocationDistance radius = 50; // meters;
// If radius is too large, registration fails automatically, so limit the radius to the maximum value
if (radius > _locationManager.maximumRegionMonitoringDistance) {
radius = _locationManager.maximumRegionMonitoringDistance;
}
CLCircularRegion* region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(latitude, longitude) radius:radius identifier:#"TEST"];
region.notifyOnEntry = YES;
region.notifyOnExit = YES;
NSLog(#"Created region");
return region;
}
-(void)monitorProximity
{
CLRegion *region = [self createRegion];
// Check if support is unavailable
if ( ![CLLocationManager isMonitoringAvailableForClass:[CLRegion class]]) {
NSLog( #"Failed to initialise region monitoring: support unavailable");
return;
}
// Check if authorised
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) {
NSLog( #"Failed to initialise region monitoring: app not authorized to use location services");
return;
} else
{
NSLog(#"Started monitoring proximity");
}
// Clear out any old regions to prevent buildup.
if ([_locationManager.monitoredRegions count] > 0)
{
for (id obj in _locationManager.monitoredRegions)
[_locationManager stopMonitoringForRegion:obj];
}
[_locationManager startMonitoringForRegion:region];
}
-(void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
NSLog(#"Started monitoring for region: %#", [region description]);
[_locationManager requestStateForRegion:region]; // check if already inside region
}
-(void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
NSLog(#"Failed to start monitoring for region: %#", [error localizedDescription]);
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"Failed Monitoring" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
NSLog(#"didDetermineState");
if (state == CLRegionStateInside) {
NSLog(#"inside");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"inside" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
return;
} else if (state == CLRegionStateOutside) {
NSLog(#"outside");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"outside" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
} else {
NSLog(#"unknown");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"unknown" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
}
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(#"didEnterRegion");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"did enter region" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(#"didExitRegion");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"did exit region" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
NSLog(#"Monitoring authorisation status is now: %#", status == kCLAuthorizationStatusAuthorized ? #"authorized" : #"not authorized");
if (status == kCLAuthorizationStatusAuthorized) {
[self monitorProximity];
}
}

Related

Check when user returns from Settings app iOS

I require location of the user in my application if in case the user has device location services disabled I am checking like this.
if([CLLocationManager locationServicesEnabled])
{
if([locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)])
{
[locationManager requestWhenInUseAuthorization];
}
}
else if(![CLLocationManager locationServicesEnabled])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Location Services are disabled please enable location services to enjoy nearby experience" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Settings", nil];
alert.tag = 103;
[alert show];
}
In my alert view I am directing the user to location settings like this
else if(alertView.tag == 103)
{
if(buttonIndex == 1)
{
NSURL*url=[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"];
[[UIApplication sharedApplication] openURL:url];
}
}
After the user comes back from settings how to get location again
You can manage your stuff in applicationWillEnterForeground because this method will get called when you come from setting app to your app.
You can write your code in this method like,
if([CLLocationManager locationServicesEnabled])
{
if([locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)])
{
[locationManager requestWhenInUseAuthorization];
}
}
Use Location Delegate method :-
if([CLLocationManager locationServicesEnabled])
{
if([locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)])
{
[locationManager requestWhenInUseAuthorization];
//Set Location Delegate
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
//Update Location start
[locationManager startUpdatingLocation];
}
}
else if(![CLLocationManager locationServicesEnabled])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Location Services are disabled please enable location services to enjoy nearby experience" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Settings", nil];
alert.tag = 103;
[alert show];
}
#pragma mark CLLocationManager Delegate
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
//NSLog(#"OldLocation %f %f", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
//NSLog(#"NewLocation %f %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude);
[locationManager stopUpdatingLocation];
}

How to scan Beacons in IOS?

I am developing an app to search nearest beacon device but not able to calling any delegate, Already I have beacons available but not finding any beacons.
Also I did not understand NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:#"3863C90B-1BA6-4A4E-ADD2-D64FF1286898"]; is static is passed or not?
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:#"3863C90B-1BA6-4A4E-ADD2-D64FF1286898"];
self.myBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
identifier:#"com.jss.myidentifire"];
self.myBeaconRegion.notifyOnEntry = YES;
[self.locationManager startMonitoringForRegion:self.myBeaconRegion];
[self.locationManager startUpdatingHeading];
[self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion];
-(void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
[locationManager requestStateForRegion:region];
}
-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
if (state == CLRegionStateInside)
{
[self locationManager:locationManager didEnterRegion:region];
}
}
- (void)locationManager:(CLLocationManager*)manager didEnterRegion:(CLRegion *)region
{
// We entered a region, now start looking for our target beacons!
self.statusLabel.text = #"Finding beacons.";
[self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"BeaconDetail" message:#"DidEnterRegion Called" delegate:self cancelButtonTitle:#"ok" otherButtonTitles:nil, nil];
[alert show];
}
-(void)locationManager:(CLLocationManager*)manager didExitRegion:(CLRegion *)region
{
// Exited the region
self.statusLabel.text = #"None found.";
[self.locationManager stopRangingBeaconsInRegion:self.myBeaconRegion];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"BeaconDetail" message:#"didExitRegion Called" delegate:self cancelButtonTitle:#"ok" otherButtonTitles:nil, nil];
[alert show];
}
-(void)locationManager:(CLLocationManager*)manager
didRangeBeacons:(NSArray*)beacons
inRegion:(CLBeaconRegion*)region
{
self.statusLabel.text = #"Beacon found!";
CLBeacon *foundBeacon = [beacons firstObject];
NSString *uuid = foundBeacon.proximityUUID.UUIDString;
NSString *major = [NSString stringWithFormat:#"%#", foundBeacon.major];
NSString *minor = [NSString stringWithFormat:#"%#", foundBeacon.minor];
NSString *accuracy = [NSString stringWithFormat:#"%f", foundBeacon.accuracy];
accuracy = [NSString stringWithFormat:#"%f", foundBeacon.accuracy];
if (foundBeacon.proximity == CLProximityUnknown) {
self.distanceLabel.text = #"Unknown Proximity";
} else if (foundBeacon.proximity == CLProximityImmediate) {
self.distanceLabel.text = #"Immediate";
} else if (foundBeacon.proximity == CLProximityNear) {
self.distanceLabel.text = #"Near";
} else if (foundBeacon.proximity == CLProximityFar) {
self.distanceLabel.text = #"Far";
}
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:uuid forKey:#"uuid"];
[dict setObject:major forKey:#"major"];
[dict setObject:minor forKey:#"minor"];
[dict setObject:accuracy forKey:#"accuracy"];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"BeaconDetail" message:[NSString stringWithFormat:#"%#",dict] delegate:self cancelButtonTitle:#"ok" otherButtonTitles:nil, nil];
[alert show];
}
Make sure you have obtained permission to scan for beacons by adding the following:
if([self.locationManager respondsToSelector:#selector(requestAlwaysAuthorization)]) {
[self.locationManager requestAlwaysAuthorization];
}
For the above to work, you also need to add a new key to your Info.plist file: NSLocationAlwaysUsageDescription with a value set to something like "This app wants to scan for beacons"
if you start the receiver when it's already in the beacon range, it's not going to fire. Just checking that you're walking far away from the beacon and then walking back into range to get it to fire?

CLLocation Manager not updated when App is in Guided Access mode

I kept Guided Access for iPad app. When the app is launched it asks for user's current location using CLLocationManager.This is working under Normal mode and updates user current location. But under Guided Access, popup ("Allow to access your location") is not shown and authorizationStatus is always kCLAuthorizationStatusNotDetermined and doesn't update current location of user . Couldn't understand what could be the problem.Searched a lot but couldn't find it.
ViewController.m :
- (void)viewDidAppear:(BOOL)animated
{
[appDelegate startLocation];
[self performSelector:#selector(CheckLocationManger) withObject:nil afterDelay:0.1];
}
-(void)CheckLocationManger
{
AppAppDelegate *appDelegate=(AppAppDelegate*)[[UIApplication sharedApplication]delegate];
if(![CLLocationManager locationServicesEnabled])
{
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:#"Whoops we can’t find you!" message:#"Location services are disabled" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
if(activityIndictr)
[activityIndictr stopAnimating];
[alert1 show];
return;
}
if([CLLocationManager locationServicesEnabled])
{
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied)
{
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:#"Whoops we can’t find you!"message:#"Location services are disabled. You can fix this by going to Settings > Privacy > Location" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
if(activityIndictr)
[activityIndictr stopAnimating];
[alert1 show];
return;
}
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusNotDetermined) //This is called
{
[self performSelector:#selector(CheckLocationManger) withObject:self afterDelay:0.1];
return;
}
}
if(![self connected])
{
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:#"Network Error" message:#"Please verify that you have internet connectivity" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
if(activityIndictr)
[activityIndictr stopAnimating];
[alert1 show];
[alert1 release];
return;
}
else {
//continue further process
}
}
AppDelegate.m
- (void)startLocation
{
self.locationManager = [[[CLLocationManager alloc] init]autorelease];
self.locationManager.pausesLocationUpdatesAutomatically=NO;
[self.locationManager setDelegate:self];
if([[[UIDevice currentDevice ]systemVersion] floatValue]>=8.0)
{
if ([self.locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization]; //is executed but popup never displays
}
}
[self.locationManager startUpdatingLocation];
}
Any suggestions would be helpful.Thank you !
At very first set NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your .plist.
Add CoreLocation.framework and import in your class.h file -> #import <CoreLocation/CoreLocation.h> then set CLLocationManagerDelegate to your class.
Declare #property (strong, nonatomic) CLLocationManager *locationManager;
Init locationManager and set default value to it.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];
[self.locationManager setDistanceFilter:200.0f];
if ([self.locationManager respondsToSelector:#selector(requestAlwaysAuthorization)]) // Or if ([self.locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)])
[self.locationManager requestAlwaysAuthorization]; // Or [self.locationManager requestWhenInUseAuthorization];
[self.locationManager startUpdatingLocation];
Implement CLLocationMAnager delegate method
#pragma mark - Location Delegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(#"updated coordinate are %#", [locations lastObject]);
CLLocation *currentLocation = [locations lastObject];
// Your code.....
}

View with a map subview bounced back to its caller when kCLAuthorizationStatusDenied

Here I have 2 views:
LoginViewController
WallViewController
After user login in LoginViewController, it will go to WallViewController which contains a map view. First it will ask user permission to access current location. If user chooses to allow the access, there will not be any problem. However, if user chooses NOT to allow the access, user will be bounced from WallViewController back to LoginViewController. What I would like to do is to have user remain in WallViewController even though current location cannot be accessed. How can I achieve that? Here below is my relevant code.
LoginViewController.m
[PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) {
// Tear down the activity view in all cases.
[activityView.activityIndicator stopAnimating];
[activityView removeFromSuperview];
if (user) {
//***************call WallViewController here*********
PAWWallViewController *wallViewController = [[PAWWallViewController alloc] initWithNibName:nil bundle:nil];
[(UINavigationController *)self.presentingViewController pushViewController:wallViewController animated:NO];
[self.presentingViewController dismissModalViewControllerAnimated:YES];
//****************************************************
} else {
// Didn't get a user.
NSLog(#"%s didn't get a user!", __PRETTY_FUNCTION__);
// Re-enable the done button if we're tossing them back into the form.
doneButton.enabled = [self shouldEnableDoneButton];
UIAlertView *alertView2 = nil;
if (error == nil) {
// the username or password is probably wrong.
NSLog(#"1");
alertView2 = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"Couldn’t log in:\nThe username or password were wrong.", nil) message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(#"Ok", nil), nil];
alertView2.tag = kSecondAlertViewTag;
} else {
// Something else went horribly wrong:
NSLog(#"2");
alertView2 = [[UIAlertView alloc] initWithTitle:[[error userInfo] objectForKey:#"error"] message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(#"Ok", nil), nil];
alertView2.tag = kSecondAlertViewTag;
}
[alertView2 show];
// Bring the keyboard back up, because they'll probably need to change something.
[usernameField becomeFirstResponder];
}
}];
WallViewController.m
- (void)viewDidLoad {
// ...
[self startStandardUpdates];
}
- (void)startStandardUpdates {
if (nil == locationManager) {
locationManager = [[CLLocationManager alloc] init];
}
locationManager.delegate = self;
// This part was added due to a location authorization issue on iOS8
// See more at: http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/
if ([self._locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)]) {
[self._locationManager requestWhenInUseAuthorization];
}
self.mapView.showsUserLocation = YES;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// Set a movement threshold for new events.
locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters;
[locationManager startUpdatingLocation];
CLLocation *currentLocation = locationManager.location;
if (currentLocation) {
PAWAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.currentLocation = currentLocation;
}
}
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
NSLog(#"%s", __PRETTY_FUNCTION__);
switch (status) {
case kCLAuthorizationStatusAuthorized:
NSLog(#"kCLAuthorizationStatusAuthorized");
// Re-enable the post button if it was disabled before.
self.navigationItem.rightBarButtonItem.enabled = YES;
[locationManager startUpdatingLocation];
break;
//**********This alert will show up, once click Ok it will go back to its caller which is LoginViewController***********
case kCLAuthorizationStatusDenied:
NSLog(#"kCLAuthorizationStatusDenied");
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"This app can’t access your current location.\n\nTo view nearby posts or create a post at your current location, turn on access for this app to your location in the Settings app under Location Services.", nil) message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(#"Ok", nil), nil];
[alertView show];
// Disable the post button.
self.navigationItem.rightBarButtonItem.enabled = NO;
}
break;
//**********************************************************************************************************************
case kCLAuthorizationStatusNotDetermined:
NSLog(#"kCLAuthorizationStatusNotDetermined");
break;
case kCLAuthorizationStatusRestricted:
NSLog(#"kCLAuthorizationStatusRestricted");
break;
default:break;
}
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(#"%s", __PRETTY_FUNCTION__);
PAWAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.currentLocation = newLocation;
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(#"%s", __PRETTY_FUNCTION__);
NSLog(#"Error: %#", [error description]);
if (error.code == kCLErrorDenied) {
[locationManager stopUpdatingLocation];
} else if (error.code == kCLErrorLocationUnknown) {
// todo: retry?
// set a timer for five seconds to cycle location, and if it fails again, bail and tell the user.
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"Error retrieving location", nil)
message:[error description]
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(#"Ok", nil), nil];
[alert show];
}
}
Given the above code, what I found after login is that there will be a popup asking whether user allows current location access. If user chooses No, there will be an alert view saying "This app can’t access your current location. To view nearby posts or create a post at your current location, turn on access for this app to your location in the Settings app under Location Services." After I click Ok, it will go back to its caller which is LoginViewController but I want it to remain in WallViewController. Need some helps here. Thank you in advance.
I changed delegate:self to delegate:nil in the below code and it solved the issue.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"This app can’t access your current location.\n\nTo view nearby posts or create a post at your current location, turn on access for this app to your location in the Settings app under Location Services.", nil) message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(#"Ok", nil), nil];

iOS: Get Coordinates on button click, then stop all location services

Right now, I have it so when a button is clicked, it starts location services, sets the latitude/longitude variables. But location still continues to be running in the background.
I want is so when I click a button it finds the latitude/longitude, all location services stop.
Here's what I have currently.
- (IBAction)startButton:(id)sender {
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
NSLog(#"%#", [self lat]);
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(#"didFailWithError: %#", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:#"Error" message:#"Failed to Get Your Location" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
[self setLat:[NSString stringWithFormat:#"%.6f", currentLocation.coordinate.latitude]];
}
}
Another problem is, if I instantly try to retrieve the value of the lat property, it returns null, most likely because it takes a second or two to find the location.
So I would also need to stop any further code to be run until the lat/long properties are set. For example, How would I stop the otherFunction from running until the latitude/longitude are found:
- (IBAction)startButton:(id)sender {
[self updateLocation];
[self otherFunction];
}
- (void)updateLocation
{
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(#"didFailWithError: %#", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:#"Error" message:#"Failed to Get Your Location" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
[self setLat:[NSString stringWithFormat:#"%.6f", currentLocation.coordinate.latitude]];
[locationManager stopUpdatingLocation]
}
}
Any help/ideas would be appreciated!
In your last function, after you verify that the currentLocation is not nil, then you should check for the accuracy of currentLocation, then call your setLat: function, then stop updating the location. See this post for more details:
CLLocationManager and accuracy issues - any experiences?

Resources