Hallo leute
bin neu bei euch...
ich arbeite schon länger an einen kleinen Projekt
ich möchte einen Geburtstags Kalender erstellen!
Den Timer hab ich schon geschafft, das Problem ist nur das er nicht bei 0 stehen bleibt sondern ins - läuft...
kann mir jemand bitte helfen
Danke Danke
bin neu bei euch...
ich arbeite schon länger an einen kleinen Projekt
ich möchte einen Geburtstags Kalender erstellen!
Den Timer hab ich schon geschafft, das Problem ist nur das er nicht bei 0 stehen bleibt sondern ins - läuft...
kann mir jemand bitte helfen
Danke Danke
Code:
[COLOR=#D200A8][FONT=Menlo]@implementation[/FONT][/COLOR][FONT=Menlo] ViewController[/FONT][FONT=Menlo]
[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]-([COLOR=#d200a8]void[/COLOR])updateLabel {[/FONT]
[FONT=Menlo] [/FONT]
[COLOR=#7E14B1][FONT=Menlo][COLOR=#000000] [/COLOR]NSDateFormatter[COLOR=#000000] *dateformatter = [[[/COLOR]NSDateFormatter[COLOR=#000000] [/COLOR][COLOR=#480088]alloc[/COLOR][COLOR=#000000]] [/COLOR][COLOR=#480088]init[/COLOR][COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [dateformatter [COLOR=#480088]setDateFormat[/COLOR]:[COLOR=#ea0000]@"dd/MM/yyyy HH:mm:SS"[/COLOR]];[/FONT]
[FONT=Menlo] [/FONT]
[COLOR=#EA0000][FONT=Menlo][COLOR=#000000] [/COLOR][COLOR=#7e14b1]NSString[/COLOR][COLOR=#000000] *fathersDay = [/COLOR]@"27/05/2013 18:03:13"[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#7e14b1]NSDate[/COLOR] *currentDate = [dateformatter [COLOR=#480088]dateFromString[/COLOR]:fathersDay];[/FONT]
[FONT=Menlo] [/FONT]
[COLOR=#7E14B1][FONT=Menlo][COLOR=#000000] [/COLOR]NSCalendar[COLOR=#000000] *gregorian = [[[/COLOR]NSCalendar[COLOR=#000000] [/COLOR][COLOR=#480088]alloc[/COLOR][COLOR=#000000]] [/COLOR][COLOR=#480088]initWithCalendarIdentifier[/COLOR][COLOR=#000000]:[/COLOR]NSGregorianCalendar[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#480088][FONT=Menlo][COLOR=#000000] [/COLOR][COLOR=#d200a8]int[/COLOR][COLOR=#000000] unitFlags = [/COLOR]NSDayCalendarUnit[COLOR=#000000] | [/COLOR]NSHourCalendarUnit[COLOR=#000000] | [/COLOR]NSMinuteCalendarUnit[COLOR=#000000] | [/COLOR]NSSecondCalendarUnit[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#7e14b1]NSDateComponents[/COLOR] *components = [gregorian [COLOR=#480088]components[/COLOR]:unitFlags [COLOR=#480088]fromDate[/COLOR]:[COLOR=#358289]today[/COLOR] [COLOR=#480088]toDate[/COLOR]:currentDate [COLOR=#480088]options[/COLOR]:[COLOR=#3a00e3]0[/COLOR]];[/FONT]
[FONT=Menlo] [/FONT]
[FONT=Menlo] [COLOR=#358289]countdownLabel[/COLOR].[COLOR=#7e14b1]text[/COLOR] = [[COLOR=#7e14b1]NSString[/COLOR] [COLOR=#480088]stringWithFormat[/COLOR]:[COLOR=#ea0000]@"%02dDays, %02dHour, %02dmin., %02dsec."[/COLOR], components.[COLOR=#480088]day[/COLOR], components.[COLOR=#480088]hour[/COLOR], components.[COLOR=#480088]minute[/COLOR], components.[COLOR=#480088]second[/COLOR] ];[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo] [/FONT]
[FONT=Menlo] [/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#d200a8]void[/COLOR])viewDidLoad {[/FONT]
[FONT=Menlo] [COLOR=#d200a8]self[/COLOR]->[COLOR=#358289]today[/COLOR] = [[COLOR=#7e14b1]NSDate[/COLOR] [COLOR=#480088]date[/COLOR]];[/FONT]
[COLOR=#480088][FONT=Menlo][COLOR=#000000] [/COLOR][COLOR=#d200a8]self[/COLOR][COLOR=#000000]->[/COLOR][COLOR=#358289]timer[/COLOR][COLOR=#000000] = [[/COLOR][COLOR=#7e14b1]NSTimer[/COLOR][COLOR=#000000] [/COLOR]scheduledTimerWithTimeInterval[COLOR=#000000]:([/COLOR][COLOR=#3a00e3]1.0[/COLOR][COLOR=#000000]) [/COLOR]target[COLOR=#000000]:[/COLOR][COLOR=#d200a8]self[/COLOR][COLOR=#000000] [/COLOR]selector[COLOR=#000000]:[/COLOR][COLOR=#d200a8]@selector[/COLOR][COLOR=#000000](updateLabel) [/COLOR]userInfo[COLOR=#000000]:[/COLOR][COLOR=#d200a8]nil[/COLOR][COLOR=#000000] [/COLOR]repeats[COLOR=#000000]:[/COLOR][COLOR=#d200a8]YES[/COLOR][COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#480088][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#d200a8]super[/COLOR][COLOR=#000000] [/COLOR]viewDidLoad[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [/FONT]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]
[/FONT]