Adding days to NSDate

Posted by karthick on Stack Overflow See other posts from Stack Overflow or by karthick
Published on 2011-11-17T09:42:54Z Indexed on 2011/11/17 9:50 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

I want add days to a date, I got many codes for this but none of them are working for me below shown is my code,please somebody help me to fix this issue

int daysToAdd=[[appDlegateObj.selectedSkuData 
                                    objectForKey:@"Release Time"] intValue];

NSTimeInterval secondsForFollowOn=daysToAdd*24*60*60;

NSString *dateStr=[contentDic objectForKey:@"Date"];

NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];

[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSDate *dateFromString=[[NSDate alloc]init];

dateFromString=[dateFormatter dateFromString:dateStr];

[dateFormatter release];

 NSDate *date=[dateFromString dateByAddingTimeInterval:secondsForFollowOn];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c