NSTimer UIDatePicker dealing with only time - ios

In an iOS app I have a view with a UIDatePicker which only selects time (hour, minute, and am/pm). Then based upon the time of the UIDatePicker, sets an NSTimer. This timer is supposed to launch daily at the time specified on the UIDatePicker. Is there anyway to set up an NSTimer with a specified hour, minute, then either am or pm without having to take the date into consideration? Being able to do this would allow me to remove a huge amount of conditional statements regarding month's, day's and years.
If this isn't possible is there a recommended approach?
Thanks!

Check out UILocalNotification:
https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/

Related

Background refresh data

I'm making an app that displays text from an array and I need to background refresh the text depending on the date at midnight. How can I background fetch this at exactly 12:00am so it shows the new text? I turned on background fetching on the file and it refreshes at about 2pm or 3pm the next day but I don't know the code to do this at exactly midnight, I'm new to all this.

CMClock Swift Example

I have two iOS devices physically separate from each other. I need them to perform a task at exactly the top of every minute and bottom of every minute (so every 30 seconds) and stay synchronized.
My initial approach was to calculate the time until the top of the next minute and set a timer until that time and then start my 30 second timer.
The problem was that the 30 second timer would drift and eventually be out of sync.
I discovered an Apple API called CMClock. I could not find an example but was wondering if anyone has used this API and if so could provide an example of how to keep two devices synchronized like I described?

Accurately delaying time between KIF waitForViewWithAccessibilityLabel and tapViewWithAccessibilityLabel

Is there a way to accurately (to thousands of a second) delay the time between waiting for a view to appear waitForViewWithAccessibilityLabel and then tapping another view tapViewWithAccessibilityLabel in KIF. In my app code I set to DateTime objects on view appear and tap but this time difference does not match the delay I put in KIF.
I have tried waitForTimeInterval and also
while(true) {
NSTimeInterval time = [[NSDate date] timeIntervalSinceDate:dateStart];
if(time > 1.678)
break;
}
but those both have errors of about 0.15 seconds. I assume that this error comes from the waitForViewWithAccessibilityLabel looking for the view to appear. Is there any way to set the start time of a the timer at the time the view is actually found? Or any other suggestions on solving this problem?
Cheers,
Mo

How to Make and automatic timer reset in Delphi 7?

Could someone tell me how to make a timer Reset after a given time ? Like i'm trying to make a clock , and i would like it to reset , and start over (like after 60 min , and start over from 0).
Have your OnTimer event update the timer's Tag property, or a separate variable, with how much time has elapsed, and then reset the timer when that value reaches your threshold.
Or you could simply run a separate timer that triggers one time after your desired interval elapses, and then reset both timers together.

what is the best way to update a timer UI

My app draws a timer (with detail to .1 seconds), for which I am currently using a NSTime which fires every .1 seconds. This feels like an absolutely terrible idea, but I'm not sure how else to do it. I don't really care about the .1 seconds updating always, but I would like it to update more than once per second. Is there a good way to do this?
NSTimer doesn't strike me as a bad approach. NSTimer is generally a very regular way to keep track of time (indeed it was used for animation timing before CADisplayLink came along). Unless you are seeing unacceptable performance of your timer display updating, I would stick with this approach.
If you are having issues with delays and inaccurate time readings, you could store the start time in NSDate, and continue to use the NSTimer but only to update the display. On each timer event firing, you then update the display by finding the NSTimeInterval from the start time to now. This way even if there is a performance issue, at least the time being display should remain accurate at the time of display.

Resources