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

  • Home
  • SEARCH
  • 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 6597695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:14:30+00:00 2026-05-25T18:14:30+00:00

I want to call a function in applicationDidEnterBackground this function is defined in other

  • 0

I want to call a function in applicationDidEnterBackground this function is defined in other controller.

I have made an object to access it but it seems that function is getting killed when called.

Here is the function it basically calculates the distance and postes a notification

 -(void)calculateDistance
{

    for (NSMutableDictionary *obj in placeName) {
        CLLocation *userLocation = [[AppHelper appDelegate] mLatestLocation];
        CLLocation *annotation1 = [[CLLocation alloc] initWithLatitude:[[obj objectForKey:@"Lat"]doubleValue] longitude:[[obj objectForKey:@"long"]doubleValue]];

        CGFloat distanceTemp = [annotation1 getDistanceFrom:userLocation];

        [obj setObject:[NSNumber numberWithFloat:distanceTemp] forKey:@"distance"];
        [annotation1 release];
    }


    if ([placeName count])
    {
        NSArray *sortedArray=[placeName sortedArrayUsingFunction:intSort context:NULL];
        self.placeName = [NSMutableArray arrayWithArray:sortedArray];
        NSMutableArray *arrayTemp = [[NSMutableArray alloc] initWithArray:placeName];


        for (int i =0; i < [placeName count]; i++) 
        {
            //                  NSArray *sortedArray=[placeName sortedArrayUsingFunction:intSort context:NULL];

            NSMutableArray *tempArray = [sortedArray objectAtIndex:i];
            //DLog(@"sortedArray%@", sortedArray);8=
            NSNumber *DistanceNum = [tempArray objectForKey:@"distance"];
            NSLog(@"distance%@:::",DistanceNum);
            NSInteger intDistance = (int)[DistanceNum floatValue];

            if(intDistance<500)
            {
                NSLog(@"ho gaya bhai");
                NSString *notifications =@"Yes";
                [[AppHelper mDataManager] setObject:notifications forKey:@"notifications"]; 

                NSLog(@"notifications:%@",notifications);
                RemindMeViewController *object = [[RemindMeViewController alloc] initWithNibName:@"RemindMeViewController" bundle:nil];
                //  RemindMeViewController *object=[[RemindMeViewController alloc]initWithNibName];

                NSLog(@"notifications set");
                [object scheduleNotification];
            }
            else
            {
                // [arrayTemp removeObjectAtIndex:i];
            }   
        }

        //after for loop is ended
        self.placeName= arrayTemp;
        DLog(@"remaining",arrayTemp);

        [arrayTemp release];
        [mTableView reloadData];    
    }       
}
  • 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-25T18:14:31+00:00Added an answer on May 25, 2026 at 6:14 pm

    How long is your function taking to complete? You only have 5 seconds to perform tasks in applicationDidEnterBackground: and return.

    From Apple’s UIApplicationDelegate Protocol Reference:

    Your implementation of this method has approximately five seconds to
    perform any tasks and return. If you need additional time to perform
    any final tasks, you can request additional execution time from the
    system by calling beginBackgroundTaskWithExpirationHandler:. In
    practice, you should return from applicationDidEnterBackground: as
    quickly as possible. If the method does not return before time runs
    out your application is terminated and purged from memory.

    You should perform any tasks relating to adjusting your user interface
    before this method exits but other tasks (such as saving state) should
    be moved to a concurrent dispatch queue or secondary thread as needed.
    Because it’s likely any background tasks you start in
    applicationDidEnterBackground: will not run until after that method
    exits, you should request additional background execution time before
    starting those tasks. In other words, first call
    beginBackgroundTaskWithExpirationHandler: and then run the task on a
    dispatch queue or secondary thread.

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

Sidebar

Related Questions

I have function getCartItems in cart.js and I want to call that function in
I have a UDF in sql server. I want to call this function at
I want to call a controller function from a view. Is that possible in
I have a problem that i want to call a function when one of
I have a simple function that I want to call in the code behind
I have following function. I want to call this function when user click on
I have a void pointer returned by dlsym(), I want to call the function
I want to call a c# function from my javascript function. I have a
I want to call a function using a variable. Is that possible in C?
I want to call a function when I have a textfield focused and then

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.