need to check remote server at a certian time

Discussion in 'iOS Programming' started by larswik, Mar 28, 2012.

  1. larswik macrumors 68000

    Sep 8, 2006
    I am closing in on the end of my app for my traveler show

    I have noticed that when I closes the app while testing it on my phone it does not quit out of the app. So when I open it again it does not execute the delegate methods like - (void)viewWillAppear:(BOOL)animated, it just seems to keep running from where it left off.

    Right now I am trying to figure out how to have the app update after 3pm for instance. If a restaurant wants to change a special they are running for that night I upload that new image to the remote site. I have a Method already that checks modification date and time of the remote file and compares it to once stored locally, It downloads new files if there is a change. Hard Part is done!

    Right now I have that Method attached to a UIbutton and when pressed it checks ALL the remote files using an NSThread so it runs in the background. But it seems pointless to check the whole site every time they press the button.

    Can someone recommend an idea, or push me in the right direction so I can schedule this? Or is there some delegate method I do not know about that is executed when your app wakes from sleep, I guess you call it sleep since it is not a full launch of your app again, otherwise I could check the current time with a Method like above.

    I can do all the coding I just need a method that executes automatically when the app wakes up again, or an idea?

  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Take a look at the UIApplicationDelegate Protocol Reference. There are a number of delegate methods for monitoring the application's state.
  3. larswik thread starter macrumors 68000

    Sep 8, 2006
  4. larswik thread starter macrumors 68000

    Sep 8, 2006
    I found something and it seems to work just fine when I test it with a simple NSLog

    - (void)applicationWillEnterForeground:(UIApplication *)application
    I have to laugh because when I looked in the appDelegate.m it was already a default method in there. Some times you can't see the forest thru the trees.

    Thanks again!

Share This Page