Code:
- (NSDate *) addDaysToDate:(NSDate*)startDate :(int)daysToAdd{
// set up date components
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:daysToAdd];
// create a calendar
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *newDate = [gregorian dateByAddingComponents:components toDate:startDate options:0];
return newDate;
[gregorian release];
[components release];
[newDate release];
}
Called to populate an NSDate property of my custom search criteria class. The addDaysToDate method lives the the appDelegate, just for ease of calling
Code:
@property (nonatomic, retain) NSDate *startDate;
@property (nonatomic, retain) NSDate *endDate;
Code:
self.startDate = [NSDate date]; // Todays date
self.endDate = [UIAppDelegate addDaysToDate:self.startDate :30];
When addDaysToDate is called with instruments in leak mode it reports
icu::GregorianCalendar
icu::NumberFormat
icu::SimpleTimeZone
NSDateComponents
NSCFCalendar