[Nstimer scheduledtimerwithtimeinterval:1.0 target:self selector: @selector (timerfiremethod:) Userinfo:nil repeats: YES];
-(void) Timerfiremethod: (nstimer*) thetimer{ id obj = [thetimer userInfo]; NSDateFormatter *f1 = [[NSDateFormatter alloc] init]; [F1 setdateformat:@ "Yyyy-mm-dd HH:mm:ss"]; NSDate *theday = [F1 datefromstring: (nsstring*) obj];// [F1 release]; Nscalendar *cal = [Nscalendar currentcalendar];//defines a Nscalendar object nsdate *today = [NSDate date];//get current time // Used to get the specific time difference unsigned int unitflags = Nsyearcalendarunit | Nsmonthcalendarunit | Nsdaycalendarunit | Nshourcalendarunit | Nsminutecalendarunit | Nssecondcalendarunit; Nsdatecomponents *d = [cal components:unitflags fromdate:today todate:theday options:0]; NSString *countdown = [NSString stringwithformat:@ "%d%d months%d days%d"%d "%d seconds", [D year],[d Month],[d Day], [D hour], [D minute], [d second]]; NSLog (@ "countdowm==%@", countdown); self.timeLabel.text = countdown; }
iOS Development Countdown