ios - Adding seconds to a self.timepicker date (for localnotification purposes) -
i want know if possible add seconds local notification? trying create loop schedule local notifications 30 seconds after each others. so, in loop below, can keep on "delaying" firedate 30 seconds after each other. don't know if question makes sense, that's best can describe problem as. think of 30 second interval, manually scheduling each notification.
for (notifs = 1, notifs <= 64, notifs ++) { uilocalnotification* localnotification = [[uilocalnotification alloc] init]; localnotification.firedate = [self.timepicker date];
//can write [self.timepicker date] + 30000?
localnotification.soundname = @"notifsound.caf"; localnotification.alertbody = @"wake up!!!"; localnotification.timezone = [nstimezone defaulttimezone]; }
thanks.
you use nsdate's datebyaddingtimeinterval:
, pass current iteration number multiplied 30.
for (notifs = 1; notifs <= 64; notifs ++) { uilocalnotification* localnotification = [[uilocalnotification alloc] init]; localnotification.firedate = [[self.timepicker date] datebyaddingtimeinterval:notifs * 30.0]; localnotification.soundname = @"notifsound.caf"; localnotification.alertbody = @"wake up!!!"; localnotification.timezone = [nstimezone defaulttimezone]; [[uiapplication sharedapplication] schedulelocalnotification:localnotification]; }
Comments
Post a Comment