Add method for passing one BOOL. Unlike NSObject's performSelector, an NSInvocation does not make any attempt to translate arguments. It just copies from the buffer passed to addArgument:atIndex: the size of paramter specified. A BOOL is one byte (as opposed to a _Bool bool, or boolean_t which are four bytes...) so it was copying just one byte of the address of the NSNumber object and invoking it with that.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
- (void) dealloc;
|
||||
- (void) addAction:(SEL)sel withTarget:(id)target;
|
||||
- (void) addAction:(SEL)sel withTarget:(id)target andObject:(id)object;
|
||||
- (void) addAction:(SEL)sel withTarget:(id)target andBool:(BOOL)b;
|
||||
// You must pass pointers to the objects to this method.
|
||||
- (void) addAction:(SEL)sel withTarget:(id)target andNumObjects:(int)num, ...;
|
||||
- (void) performOnMainThread;
|
||||
@@ -16,6 +17,9 @@
|
||||
|
||||
#define ADD_ACTION0(mt, t, s) [mt addAction:@selector(s) withTarget:(t)]
|
||||
#define ADD_ACTION1(mt, t, s, o) [mt addAction:@selector(s) withTarget:(t) andObject:(o)]
|
||||
#define ADD_ACTIONb(mt, t, s, b) [mt addAction:@selector(s) withTarget:(t) andBool:(b)]
|
||||
#define ADD_ACTIONn(mt, t, s, n, ...) \
|
||||
[mt addAction:@selector(s) withTarget:(t) andNumObjects:(n), ## __VA_ARGS__]
|
||||
|
||||
/*
|
||||
* (c) 2006 Steve Checkoway
|
||||
|
||||
@@ -36,6 +36,11 @@
|
||||
[self addAction:sel withTarget:target andNumObjects:1, &object];
|
||||
}
|
||||
|
||||
- (void) addAction:(SEL)sel withTarget:(id)target andBool:(BOOL)b
|
||||
{
|
||||
[self addAction:sel withTarget:target andNumObjects:1, &b];
|
||||
}
|
||||
|
||||
- (void) addAction:(SEL)sel withTarget:(id)target andNumObjects:(int)num, ...
|
||||
{
|
||||
NSMethodSignature *sig = [target methodSignatureForSelector:sel];
|
||||
|
||||
Reference in New Issue
Block a user