Pregunta

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];
¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top