This is NSTimer.rtf in view mode; [Download] [Up]
paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc. All Rights Reserved. s4 li100 fi0 ri1007 ql f0 b fs36 fs100 fs36 NSTimer pard s11 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject fs20 fs28 s6 f0 b fs24 Conforms To:tab b0 fs28 f1 NSObject (NSObject) fs20 fs28 s7 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSTimer.h fs20 fs28 pard s16 li100 fi0 ri1007 ql f0 b fs28 fs20 fs28 Class Description fs14 fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 fs28 NSTimer creates timer objects. A timer object waits until a certain time interval has elapsed and then fires, sending a specified message to a specified object. For example, you could create an NSTimer that sends a message to a window, telling it to update itself, after a certain time interval. fs16 fs28 NSTimer objects work in conjunction with NSRunLoop objects. NSRunLoops control loops that wait for input, and they use NSTimers to help determine the maximum amount of time they should wait. When the NSTimer'27s time limit has elapsed, the NSRunLoop fires the NSTimer (causing its message to be sent), then checks for new input. fs16 fs28 There are several ways to create an NSTimer object. The b scheduledTimerWithTimeIntervalb0 ... class methods automatically register the new NSTimer with the current NSRunLoop object in default mode. The b timerWithTimeIntervalb0 ... class methods create NSTimers that the user may register at a later time by sending the message b addTimer:forMode:b0 to the NSRunLoop. If you specify that the NSTimer should repeat, it will automatically reschedule itself after it fires. If a delay occurs when a timer is scheduled to fire, the timer will not fire. For example, suppose you used the following statement to create a timer: fs16 fs28 pard s5 li1231 fi0 ri1007 ql f2 fs20 timer = [NSTimer scheduledTimerWithTimeInterval:0.5 invocation:anInvocation repeats:YES]; pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 fs28 fs16 fs28 This statement creates a timer will schedule itself to fire after 0.5 seconds, 1 second, 1.5 seconds, and so on from the time this statement is executed. Suppose there was a 2 second delay because NSRunLoop was busy processing input. The timer takes this delay into consideration and will skip intervals that were already missed when computing the next scheduled fire date. fs16 fs28 There is no method that removes the association of an NSTimer from an NSRunLoop'd0send the NSTimer the b invalidateb0 message instead. b invalidateb0 disables the NSTimer, so it will no longer affect the NSRunLoop. fs16 fs28 See the NSRunLoop class description for more information on NSRunLoops. fs16 fs28 As a consequence of being a subclass of NSObject, NSTimer conforms to the NSCoding protocol. In practice, however, NSTimers are not encoded nor archived. fs16 fs28 pard s16 li100 fi0 ri1007 ql f0 b fs24 fs28 Creating a Timer Object fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 + (NSTimer *)b scheduledTimerWithTimeInterval:b0 (NSTimeInterval)i seconds s9 li7030 fi-6553 fi-5796 i0 b invocation:b0 (NSInvocation *)i anInvocationi0 tab Returns a new NSTimer object and registers it with the b repeats:b0 (BOOL)i repeatsi0 tab tab current NSRunLoop in the default mode. After i secondsi0 seconds have elapsed, the NSTimer fires, sending i anInvocationi0 '27s message to its target. If i repeatsi0 is YES, the NSTimer will repeatedly reschedule itself. s8 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 + (NSTimer *)b scheduledTimerWithTimeInterval:b0 (NSTimeInterval)i seconds s9 li7030 fi-6553 fi-5796 i0 b target:b0 (id)i anObjecti0 tab Returns a new NSTimer object and registers it with the b selector:b0 (SEL)i aSelectori0 tab tab current NSRunLoop in the default mode. After i secondsi0 b userInfo:b0 (id)i anArgumentb i0 tab b0 tab seconds have elapsed, the NSTimer fires, sending the b repeats:b0 (BOOL)i repeatsi0 tab tab message b [anObject aSelector:self]b0 . If i anObjecti0 needs more information, it can send the NSTimer a b userDatab0 message to retrieve i anArgumenti0 . If i repeatsi0 is YES, the NSTimer will repeatedly reschedule itself. s8 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 + (NSTimer *)b timerWithTimeInterval:b0 (NSTimeInterval)i seconds s9 li7030 fi-6553 fi-5796 i0 b invocation:b0 (NSInvocation *)i anInvocationi0 tab Returns a new NSTimer that, if registered, will fire after b repeats:b0 (BOOL)i repeatsi0 tab tab i secondsi0 seconds. Upon firing, the NSTimer sends i anInvocationi0 '27s message to its target. If i repeatsi0 is YES, the NSTimer will repeatedly reschedule itself. s8 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 + (NSTimer *)b timerWithTimeInterval:b0 (NSTimeInterval)i seconds s9 li7030 fi-6553 fi-5796 i0 b target:b0 (id)i anObjecti0 tab Returns a new NSTimer that, if registered, will fire after b selector:b0 (SEL)i aSelectori0 tab tab i secondsi0 seconds. Upon firing, the NSTimer sends the b userInfo:b0 (id)i anArgumentb i0 tab b0 tab message b [anObject aSelector:self]b0 . If i anObjecti0 needs b repeats:b0 (BOOL)i repeatsi0 tab tab more information, it can send the NSTimer a b userDatab0 message to retrieve i anArgumenti0 . If i repeatsi0 is YES, the NSTimer will repeatedly reschedule itself. pard s16 li100 fi0 ri1007 ql f0 b fs48 fs28 Firing the Timer fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (void)b fireb0 tab Causes the NSTimer'27s message to be dispatched to its target. pard s16 li100 fi0 ri1007 ql f0 b fs48 fs28 Stopping the Timer fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (void)b invalidateb0 tab Stops the NSTimer from ever firing again. pard s16 li100 fi0 ri1007 ql f0 b fs48 fs28 Getting Information About the NSTimer fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (NSDate *)b fireDateb0 tab Returns the date that the NSTimer will next fire. fi-6552 fs16 fs28 fi-6552 {f3 -} b userInfob0 tab Additional data that the object receiving NSTimer'27s message can use. }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.