Merge pull request #9 from gunyarakun/fix-typo
[cocotron.git] / Foundation / NSTimer / NSTimer_targetAction.m
blob1854fab985e3630bf7d5c1a94b9c87e1f5fce18a
1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
9 // Original - Christopher Lloyd <cjwl@objc.net>
10 #import <Foundation/NSTimer_targetAction.h>
11 #import <Foundation/NSString.h>
13 @implementation NSTimer_targetAction
15 -initWithFireDate:(NSDate *)date interval:(NSTimeInterval)interval target:target selector:(SEL)selector userInfo:userInfo repeats:(BOOL)repeats {
16    [super initWithFireDate:date interval:interval repeats:repeats];
18    _userInfo=[userInfo retain];
19         _target=[target retain]; // Apple docs say it's retained
20    _selector=selector;
22    return self;
25 -initWithTimeInterval:(NSTimeInterval)timeInterval repeats:(BOOL)repeats
26   userInfo:userInfo target:target selector:(SEL)selector {
28    [super initWithTimeInterval:timeInterval repeats:repeats];
30    _userInfo=[userInfo retain];
31    _target=[target retain]; // Apple docs say it's retained
32    _selector=selector;
34    return self;
38 -(void)dealloc {
39    [_userInfo release];
40    _userInfo=nil;
41         [_target release];
42    _target=nil;
43    [super dealloc];
47 -(void)fire {
48    [_target performSelector:_selector withObject:self];
49    [super fire];
53 -(void)invalidate {
54    _isValid=NO;
55    [_userInfo release];
56    _userInfo=nil;
57         [_target release];
58    _target=nil;
59    _selector=NULL;
63 -userInfo {
64    return _userInfo;
67 -(NSString *)description {
68    return [NSString stringWithFormat:@"<%@ 0x%x: %s>",isa,self,sel_getName(_selector)];
71 @end