objective c - How to set alarm on selected weekdays(MonDay,Sunday) in ios. (Localnotification) -
hi friends doing alarm application in had requierment repeat alarm selected days(monday, tuesday,--). once select monday alarm fire on every monday. how buddy suggest me.
advance thanks.
when notification fire running 7 week days.
nsdate *localdate = [nsdate date]; nsdateformatter *dateformatter1 = [[[nsdateformatter alloc]init]autorelease]; dateformatter1.dateformat = @"eeee mmmm d, yyyy"; nsstring *datestring = [dateformatter1 stringfromdate: localdate]; nslog(@"date:%@",datestring); (int i=0; i<8; i++) { // how day add int adddayscount = i; // creating , configuring date formatter instance nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"eeee mmmm d, yyyy"]; // retrieve nsdate instance stringified date presentation nsdate *datefromstring = [dateformatter datefromstring:datestring]; // nslog(@"dateformmater:%@",datefromstring); // create , initialize date component instance nsdatecomponents *datecomponents = [[nsdatecomponents alloc] init]; [datecomponents setday:adddayscount]; // retrieve date increased days count nsdate *newdate = [[nscalendar currentcalendar] datebyaddingcomponents:datecomponents todate:datefromstring options:0]; nsstring* weekdaystring=[dateformatter stringfromdate:newdate]; nslog(@"new date: %@", [dateformatter stringfromdate:newdate]); //here check selected week in selectedweeks array add notification }
Comments
Post a Comment