How to set the repeat UILocal Notifications on the select list of Weekdays
iphone, localnotification, objective-c, uilocalnotification
Solution
The API for UILocalNotification is very limited in this regard - you'll have to manually schedule 4 events repeating weekly on the days that the user selects.
An example of scheduling a repeat timer for monday would look like this
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.weekday = 2; // sunday = 1 ... saturday = 7
dateComponents.hour = 10;
UILocalNotification *notification = //...
notification.repeatInterval = NSWeekCalendarUnit;
notification.fireDate = [calendar dateFromComponents:dateComponents];
The day numbers can be found in the NSDateComponents Class Reference
Problem
I have implemented UILocal Notification using the following link http://useyourloaf.com/blog/2010/07/31/adding-local-notifications-with-ios-4.html And i have modified it to set the repet Notifications on each day by using ``` //To set the repeat notification notif.repeatInterval = NSDayCalendarUnit; ``` For exampke ex Every day at 10.00 AM But my requirement is user needsto set the notification on selected Week Days (Monday to saturDay) why because user may have weekly holidays like (SaturDay and Sunday) / Friday - Sunday) / Some other days.. on the `week offs he shouldn't fire the notifications.` So we felicitate user to set the selected Working days and the notifications will set on those days only.. once user set the notifications. `For ex:` we have list of weekday Sun, MOn, Tue, Wed, Thu, Fri, Saturday on those user selects Monday, Tuesday,WednesDay, Thursday. and set at 10Am Then the notification will fire on every day 10.AM of these days. How to do it