我有一个奇怪的 NSTimeIntervall 和 NSDate 内存泄漏。这是我的代码:
NSTimeInterval interval = 60*60*[[[Config alloc] getCacheLifetime] integerValue];
NSDate *maxCacheAge = [[NSDate alloc] initWithTimeIntervalSinceNow:-interval];
if ([date compare:maxCacheAge] == NSOrderedDescending) {
return YES;
} else {
return NO;
}
date 只是一个 NSDate 对象,这应该没问题。仪器告诉我“间隔”泄漏,但我不太明白,我怎样才能释放一个非对象?该函数在我在此处发布的代码片段之后结束,因此根据我的理解间隔应该会自动解除分配。
非常感谢!