【发布时间】:2012-11-29 07:58:33
【问题描述】:
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
【问题讨论】:
-
与上一个问题相同的问题。你
alloc所以你必须在最后release它或在创建时autorelease它!
标签: ios