所以我有一個對象,它代表在iPhone屏幕上繪製的一條線。我還有一個在屏幕上移動的球,當球和線交叉時,繩子就有了生命。對於我目前的積累,我收到此錯誤不斷,有沒有崩潰,但是球停在屏幕上移動:timeIntervalSinceDate給出exc_bad_access或autorelease錯誤
2011-08-18 11:00:05.436 myProgram [192:5e03] * __NSAutoreleaseNoPool() :對象0x1531c0類NSCFString自動釋放與地方沒有游泳池 - 剛剛泄露
Line.h: @interface行:NSObject的{
//time properties
NSTimeInterval life;
NSDate *startTime;
NSDate *currentTime;
}
//time properties
@property (nonatomic, retain) NSDate *startTime;
-(void) updateLife;
-(void) beginLifeTracking;
@end
Line.m
@synthesize startTime;
-(void)beginLifeTracking {
[self.startTime release]; //not sure if self is necessary here but startTime is released
//in case the same string is hit again
self.startTime = [NSDate date];
startTime = [NSDate dateWithTimeIntervalSince1970:0];
//NSLog(@"Time Interval: %f",startTime);
}
-(void) updateLife {
currentTime = [[NSDate date] retain];
NSLog(@"breakpoint1");
life = [currentTime timeIntervalSinceDate:self.startTime];
[currentTime release];
}
我假設這是某種內存管理錯誤,但我所有的嘗試,以補救它失敗。我真的很感激我在這裏做錯了一個解釋。謝謝!
你在做主線程還是後臺線程? – cpjolicoeur
我不知道如何弄清楚,我沒有做任何事情來告訴它在特定的線程上運行。 – turbo