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