Вопрос

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];
Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top