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 7493093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:45:12+00:00 2026-05-29T16:45:12+00:00

I am trying to write a method to return the current location. While I’m

  • 0

I am trying to write a method to return the current location. While I’m waiting a period of 30sec, 1 min, or 2 minutes (set in settings) I display an alert view. I allow the user to bypass the timer wait with an alertView button accepting the current accuracy which I will display and update in the alert view. My code has a couple of holes in it I need help with. Essentially, it is to know how to have the getCurrentLocation method wait on the timer. I can’t just use a delay because I plan to force the timer to expire if the user hits the button or if the location accuracy is met (this is checked in timer). Here is the code:

- (void)timerFireMethod {
    static int elapsedTime = 0;
    elapsedTime++;
    if (elapsedTime >= gpsTimeout) {
        [locationManager stopUpdatingLocation];
        elapsedTime = 0; // reset static variable
        // !!! How do I do the following !!!
        //  do something to allow getCurrentLocation to return
    }
    if ((currentLocation.horizontalAccuracy <= gpsDesiredAccuracy) & (currentLocation.verticalAccuracy <= 2*gpsDesiredAccuracy)) {
        [locationManager stopUpdatingLocation];
        elapsedTime = 0; // reset static variable
        //  do something to allow getCurrentLocation to return
    }
}

- (CLLocation *)getCurrentLocation {
    // check if current accuracy is good enough and return if true
    if ((currentLocation.horizontalAccuracy <= gpsDesiredAccuracy) & (currentLocation.verticalAccuracy <= 2*gpsDesiredAccuracy)) {
        [locationManager stopUpdatingLocation];
        return currentLocation;
    } else {
        // show alert with count down timer
        UIAlertView *gpsAlertView = [[UIAlertView alloc] initWithTitle:nil message:@"tbd put in timer and list location accuracy updates" delegate:self cancelButtonTitle:@"Continue With Current Accuracy" otherButtonTitles:nil];
        [gpsAlertView show];
        // start timer
        NSTimer *gpsTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                                         target:self selector:@selector(timerFireMethod:)
                                                       userInfo:nil repeats:YES];

        // !!! How do I do the following !!!
        // wait for when timer expires,
        // the user to press "Continue With Current Accuracy" button (can force timer to expire?)   
        return currentLocation;
    }
}
  • 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-05-29T16:45:15+00:00Added an answer on May 29, 2026 at 4:45 pm

    The way to wait on any timer or for any accelerometer or user event is to simply exit the current method back to the UI run loop by using a return statement.

    Anything you want done after the wait can go in the timer or event callback method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a method to return true or false whether a product
I am trying to write a method which will return me a code corresponding
I am trying to write a method using reflection to return all classes that
I'm trying to write a method that will return a list of DateTimes representing
I am trying to write a generic Parse method that converts and returns a
I'm trying to write a method like this: public static T Test<T>() { if
I'm trying to write a method that acts as a setter and takes some
I am trying to write a method, that takes a ComboBox, a DataTable and
I'm trying to write a method to reduce the size of any image 50%
I'm trying to write an extension method to insert data into a dictionary of

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.