@@ -13,10 +13,14 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" + +#ifdef OF_HAVE_BLOCKS +typedef void (^of_timer_block_t)(void); +#endif @class OFDate; /** * \brief A class for creating and firing timers. @@ -27,10 +31,13 @@ double interval; id target, object1, object2; SEL selector; uint8_t arguments; BOOL repeats; +#ifdef OF_HAVE_BLOCKS + of_timer_block_t block; +#endif } /** * \brief Creates and schedules a new timer with the specified time interval. * @@ -82,10 +89,25 @@ selector: (SEL)selector object: (id)object1 object: (id)object2 repeats: (BOOL)repeats; +#ifdef OF_HAVE_BLOCKS +/** + * \brief Creates and schedules a new timer with the specified time interval. + * + * \param interval The time interval after which the timer should be executed + * when fired + * \param repeats Whether the timer repeats after it has been executed + * \param block The block to invoke when the timer fires + * \return A new, autoreleased timer + */ ++ scheduledTimerWithTimeInterval: (double)interval + repeats: (BOOL)repeats + block: (of_timer_block_t)block; +#endif + /** * \brief Creates a new timer with the specified time interval. * * \param interval The time interval after which the timer should be executed * when fired @@ -134,10 +156,25 @@ target: (id)target selector: (SEL)selector object: (id)object1 object: (id)object2 repeats: (BOOL)repeats; + +#ifdef OF_HAVE_BLOCKS +/** + * \brief Creates a new timer with the specified time interval. + * + * \param interval The time interval after which the timer should be executed + * when fired + * \param repeats Whether the timer repeats after it has been executed + * \param block The block to invoke when the timer fires + * \return A new, autoreleased timer + */ ++ timerWithTimeInterval: (double)interval + repeats: (BOOL)repeats + block: (of_timer_block_t)block; +#endif /** * \brief Initializes an already allocated timer with the specified time * interval. * @@ -192,10 +229,28 @@ target: (id)target selector: (SEL)selector object: (id)object1 object: (id)object2 repeats: (BOOL)repeats; + +#ifdef OF_HAVE_BLOCKS +/** + * \brief Initializes an already allocated timer with the specified time + * interval. + * + * \param fireDate The date at which the timer should fire + * \param interval The time interval after which to repeat the timer, if it is + * a repeating timer + * \param repeats Whether the timer repeats after it has been executed + * \param block The block to invoke when the timer fires + * \return An initialized timer + */ +- initWithFireDate: (OFDate*)fireDate + interval: (double)interval + repeats: (BOOL)repeats + block: (of_timer_block_t)block; +#endif /** * \brief Fires the timer, meaning it will execute the specified selector on the * target. */