title: Properly utilize a timer in xcode to change main viewcontrollers values
body: <p>In my project I have 1 main view controller that I need values changed on, such as UILabels, and variables.</p>
  
  <p>I also need to have a timer constantly running as soon as the user first opens up the app.</p>
  
  <p>What I currently have is a timer, that's calling a function in the appdelegate every say, minute, and when it's in that function, I will have an if statement detect when it's midnight. When it's midnight, I want to reset a bunch of values on the main view controller. </p>
  
  <p>So, I need this timer running again, as soon as the user opens the app for the first time. It needs to be running when it's completely closed, and when in the background, say when a user hits the home button and doesn't shut it.</p>
  
  <p>My main questions are, what are the functions I'm supposed to use in the appdelegate for this?
  Right now it seems that the timer will only fire after I completely close the tasks/app in xcode and go back into it, then I'll see my values are reset. Not when I simply go to home in the simulator.</p>
  
  <p>Later on, I found that even if I temporarily skirt around these needs and get the midnight function to fire from the timer, when I'm in the main VC, it's not resetting the values, such as my UILabel...even though that section of code is firing due to an alert I put there.</p>
  
  <p>So, My question here is, Under what function and I supposed to put my midnight function in, to be able to change values when the user is actively in the app, say at midnight, AND when they aren't in the APP. when the app isn't running, I need the timer to still trigger the midnight function every hour or minute and when it actually doers hit midnight, I need it to each into the main VC and reset the values so that when the user does finally open the app and loads that main VC, those values will be reset.</p>
  
  <p>Essentially, users are tracking some numbers throughout the day, and once midnight hits, those numbers will be reset, so when the user opens the app in the day, he'll see 0.</p>
  
  <p>Thanks.</p>