Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
704 views
in Technique[技术] by (71.8m points)

iphone - Repeating a Local Notification after every 14 days(two weeks)?

In my app i've to set repetitive UILocalNotification. I'm able to set repeatInterval as daily, weekly etc by doing

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.repeatInterval = NSDayCalendarUnit; // or any other calendarUnit

Ok..it's fine, but i've to set repeatInterval for every 14 days. i came to know from this link that we can only use one of the NSCalendarUnit repeat intervals. So you can have a repeat interval of one minute or one hour or one day but not five minutes or three hours or 14 days. Any Idea about this limitation in iOS 5 or later(that article was written for iOS 4.0)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can only set the repeat interval to a calendar unit. In order to get the right time interval you may have to set several notifications though.

If you for instance wanted a notification every 20 minutes you would have to create 3 notifications 20 minutes apart with a repeat interval of NSHourCalendarUnit.

The problem in your case is that the next thing up from the week unit is a month but a month is not exactly 4 weeks.

To actually set a notification for every 14 days you will have to create 26 notifications with a repeat interval of NSYearCalendarUnit.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...