objective c - NSTimeinterval problem for date in iphone sdk -
i converting date nstimeinterval code below:
nsdate *currentdate = [nsdate date]; nstimeinterval currentyinterval = [appdelegate settimeinterval:currentdate]; nsdate *expirydate = [appdelegate setreversedate:warrobj.expiredon]; nstimeinterval expiryinterval = [appdelegate settimeinterval:expirydate]; //here getting nil value , exception generated. //it happens in 3.1 -(nstimeinterval )settimeinterval:(nsdate *)selecteddate { nsdateformatter *dateformatter = [[nsdateformatter alloc]init] ; [dateformatter setdateformat:@"dd-mmm-yyyy 00:00:00"]; nsstring *currstr = [dateformatter stringfromdate:selecteddate]; nsdate *newcurrentdate = [dateformatter datefromstring:currstr]; nstimeinterval timeinterval = [newcurrentdate timeintervalsincereferencedate]; [dateformatter release]; return timeinterval; }
can suggest me how rid of this.
thanks all, madan.
nstimeinterval
typedef
double
, not object:
getting time interval:
nstimerinterval timeinterval = [[nsdate date] timeintervalsincereferencedate]; nsdate *expirydate = [appdelegate setreversedate:warrobj.expiredon]; nstimeinterval expiryinterval = [expirydate timeintervalsincereferencedate];
creating date time interval:
nstimeinterval onehour = 60*60; nsdate *date = [nsdate datewithtimeintervalsincereferencedate:timeinterval - onehour];
Comments
Post a Comment