ios - Calling a Method at NSDate -


i'm trying call method @ time , date (using nsdate) can't work out how it.

i don't want use nstimer because becomes paused when app goes background or closed. don't want run 1 in background either because solves half of problem , wasteful way of doing in opinion. thought if fire method @ nsdate in future, when app opened again can see if current date has passed fire date , whether call instantly or carry on waiting.

i suppose i'm looking uilocalnotification, without notification.

i hoping there simple way of doing can't seem find, appreciated.

at first, sounded me want performselector:withobject:afterdelay: method. have nsdate *date when want call selector.

nstimeinterval delay = [date timeintervalsincenow]; [self performselector:@selector(methodtofire) withobject:nil afterdelay:delay]; 

of course, won't live past runtime, you've pretty outlined need already. save date somewhere (there many ways that), , check against in applicationdidbecomeactive. can use same timeintervalsincenow method used above. (if date has past, the interval negative.)

if ( [date timeintervalsincenow] <= 0 ) {     // something... } 

Comments