@@ -30,10 +30,13 @@ #endif #import "OFInvalidArgumentException.h" @implementation OFTimer +@synthesize timeInterval = _interval, isValid = _valid; +@synthesize OF_inRunLoop = _inRunLoop; + + (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval target: (id)target selector: (SEL)selector repeats: (bool)repeats { @@ -407,34 +410,33 @@ objc_autoreleasePoolPop(pool); } - (OFDate*)fireDate { - OF_GETTER(_fireDate, true) + return [[_fireDate copy] autorelease]; } - (void)setFireDate: (OFDate*)fireDate { [self retain]; @try { @synchronized (self) { + OFDate *old; + [_inRunLoop OF_removeTimer: self]; - OF_SETTER(_fireDate, fireDate, true, 0) + old = _fireDate; + _fireDate = [fireDate copy]; + [old release]; [_inRunLoop addTimer: self]; } } @finally { [self release]; } } -- (of_time_interval_t)timeInterval -{ - return _interval; -} - - (void)invalidate { _valid = false; [_target release]; @@ -443,15 +445,10 @@ _target = nil; _object1 = nil; _object2 = nil; } -- (bool)isValid -{ - return _valid; -} - #ifdef OF_HAVE_THREADS - (void)waitUntilDone { [_condition lock]; @try { @@ -464,11 +461,6 @@ } @finally { [_condition unlock]; } } #endif - -- (void)OF_setInRunLoop: (OFRunLoop*)inRunLoop -{ - OF_SETTER(_inRunLoop, inRunLoop, true, 0) -} @end