/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
- //
- // CallFuncWithObject.m
- // ObjectAL
- //
- // Created by Karl Stenerud.
- //
- #import "CallFuncWithObject.h"
- @implementation CallFuncWithObject
- + (id) actionWithTarget:(id)target
- selector:(SEL)selector
- object:(id) object
- {
- return [[[self alloc] initWithTarget:target selector:selector object:object] autorelease];
- }
- + (id) actionWithTarget:(id)target
- selector:(SEL)selector
- object:(id) object
- object:(id) object2
- {
- return [[[self alloc] initWithTarget:target selector:selector object:object object:object2] autorelease];
- }
- - (id) initWithTarget:(id)targetIn
- selector:(SEL)selectorIn
- object:(id) objectIn
- {
- if(nil != (self = [super initWithTarget:targetIn selector:selectorIn]))
- {
- object = [objectIn retain];
- twoObjects = NO;
- }
- return self;
- }
- - (id) initWithTarget:(id)targetIn
- selector:(SEL)selectorIn
- object:(id) objectIn
- object:(id) object2In
- {
- if(nil != (self = [super initWithTarget:targetIn selector:selectorIn]))
- {
- object = [objectIn retain];
- object2 = [object2In retain];
- twoObjects = YES;
- }
- return self;
- }
- - (void) dealloc
- {
- [object release];
- [object2 release];
- [super dealloc];
- }
- -(void) execute
- {
- if(twoObjects)
- {
- [targetCallback performSelector:selector withObject:object withObject:object2];
- }
- else
- {
- [targetCallback performSelector:selector withObject:object];
- }
- }
- @end