PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Classes/CallFuncWithObject.m

http://github.com/kstenerud/ObjectAL-for-iPhone
Objective C | 73 lines | 57 code | 10 blank | 6 comment | 5 complexity | 0e797c1d7709337a79d4df574498b8ed MD5 | raw file
 1//
 2//  CallFuncWithObject.m
 3//  ObjectAL
 4//
 5//  Created by Karl Stenerud.
 6//
 7
 8#import "CallFuncWithObject.h"
 9
10
11@implementation CallFuncWithObject
12
13+ (id) actionWithTarget:(id)target
14			   selector:(SEL)selector
15				 object:(id) object
16{
17	return [[[self alloc] initWithTarget:target selector:selector object:object] autorelease];
18}
19
20+ (id) actionWithTarget:(id)target
21			   selector:(SEL)selector
22				 object:(id) object
23				 object:(id) object2
24{
25	return [[[self alloc] initWithTarget:target selector:selector object:object object:object2] autorelease];
26}
27
28- (id) initWithTarget:(id)targetIn
29			 selector:(SEL)selectorIn
30			   object:(id) objectIn
31{
32	if(nil != (self = [super initWithTarget:targetIn selector:selectorIn]))
33	{
34		object = [objectIn retain];
35		twoObjects = NO;
36	}
37	return self;
38}
39
40- (id) initWithTarget:(id)targetIn
41			 selector:(SEL)selectorIn
42			   object:(id) objectIn
43			   object:(id) object2In
44{
45	if(nil != (self = [super initWithTarget:targetIn selector:selectorIn]))
46	{
47		object = [objectIn retain];
48		object2 = [object2In retain];
49		twoObjects = YES;
50	}
51	return self;
52}
53
54- (void) dealloc
55{
56	[object release];
57	[object2 release];
58	[super dealloc];
59}
60
61-(void) execute
62{
63	if(twoObjects)
64	{
65		[targetCallback performSelector:selector withObject:object withObject:object2];
66	}
67	else
68	{
69		[targetCallback performSelector:selector withObject:object];
70	}
71}
72
73@end