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];
Était-ce utile?

La 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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top