NSDate *today = [[NSDate alloc] init];
NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *onset = [[NSDateComponents alloc] init];
[onset setMonth:monthsStart];
NSDate *fromDate = [gregorian dateByAddingComponents:onset toDate:today options:0];
[onset setMonth:monthsEnd];
NSDate *toDate = [gregorian dateByAddingComponents:onset toDate:today options:0];
it says the following :-
- Method returns an Objective-C object with a +1 retain count
- Object leaked: object allocated and stored into
todayis not referenced later in this execution path and has a retain count of +1
The leak is because you are not releasing
today. Please use[today release]and release the same. The same is the case withcalenderandonset. Immediately after the lineNSDate *toDate = [gregorian dateByAddingComponents:onset toDate:today options:0];, please release all these params.Also please go through this documentation, Advanced Memory Management Programming Guide