Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:09:18+00:00 2026-06-15T01:09:18+00:00

In Xcode 4.5 apple introduced apple new maps. My application heavliy requires map services.

  • 0

In Xcode 4.5 apple introduced apple new maps. My application heavliy requires map services. And I have noticed in my application it shows the wrong current location until you delete the app and reopen it shows the right current location (Sometimes it doesn’t). Just to mention I was connected to 4G when it show the wrong current location. Is there a way to fix this bug because my application heavily needs the right location. Thanks in advance. If you could provide code it would help a lot…Edit: Same Issue in Apple Map App

My Code:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
    {

    }

    if (!oldLocation)
        totalDistance = 0.0;
    else
        totalDistance += [newLocation distanceFromLocation:oldLocation];

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:09:19+00:00Added an answer on June 15, 2026 at 1:09 am

    The old approach from apple docs seems still working in iOS6 (didn’t notice this in my active app (it tracks user’s route via gps))

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    
        NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
        if (locationAge > 5.0) return;
        if (newLocation.horizontalAccuracy < 0) return; 
    
        // proceed with coords here
    }
    

    UPDATE from the discussion:
    Calculating total and current distance could be done like this (excluding some minor stuff):

    // somewhere at the top
    CLLocation* lastUsedLocation = nil; // last location used in calculation
    CLLocation* pointA = nil;  // start of the track
    double totalDistance = 0;  // total distance of track
    double currentDistance = 0; // distance between startTrack point and current location
    ...
    
    // when you start updating location:
    - (void) startTracking {
        lastUsedLocation = nil;
        pointA = nil;
        totalDistance = 0;
        currentDistance = 0;
        [locationManager startUpdatingLocation];
    }
    ...
    
    
    // location update callback
     - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
        NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; 
        if (locationAge > 5.0) return;  // filter cached
        if (newLocation.horizontalAccuracy < 0) return; // filter invalid
    
        if(!pointA) pointA = [newLocation retain]; 
    
        if(lastUsedLocation) 
        { 
            totalDistance += [newLocation distanceFromLocation:lastUsedLocation]; 
        } 
        currentDistance = [pointA distanceFromLocation:newLocation]; 
        [lastUsedLocation release]; 
        lastUsedLocation = [newLocation retain]; 
    }
    

    If you need the option to turn off background location on purpose you disable it manually like:

    - (void)applicationDidEnterBackground:(UIApplication *)application {
        if(backgroundLocationDisabled)
        {
            [locationManager stopUpdatingLocation];
            // additional stuff
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With Xcode 4 on OS X 10.7, Lion, Apple introduced a fantastic new way
We have got the new Apple editor Xcode 4, I found some features from
I have already tried multiple ways. defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME=YourNameHere;}' Also i've tried
I noticed that Xcode (or more precisely the Apple LLVM compiler?) does not longer
I have an Apple laptop with Snow Leopard (10.6.7) and I need an Xcode
i am using the new xcode 4.5, i have this lines of code on
In learning about Core Data, I've noticed how (in Xcode's templates) Apple directly used
I have installed Xcode from Apple Store and run the PhoneGap installer libs/ios from
With the latest version of Xcode from Apple, I have the following problem. Upon
Possible Duplicate: Apple LLVM 4.0 new features on Xcode 4.4 (Literals) I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.