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];
它说以下内容:-
- 方法返回一个具有 +1 保留计数的 Objective-C 对象
- 对象泄漏:分配和存储到
today
的对象在此执行路径中稍后未引用,并且保留计数为 +1