Question

I need to make a NSDate to set a local notification so it fires every 2 hours or well at every specific time.

I don't know how to do this though, so it will be greatly appreciated if someone can show me how...

I saw something like this but I don't know how it works:

notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60 * 60];
Was it helpful?

Solution

60*60 is 3600 seconds from now, so logically:

notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60 * 120];

Which will fire every two hours, for more information on dateWithTimeIntervalSinceNow see the NSDate Class Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top