question about selector as argument
question about selector as argument
- Subject: question about selector as argument
- From: "Ivan S. Kourtev" <email@hidden>
- Date: Sat, 18 Jun 2005 09:34:48 -0400
Hi,
I have a somewhat silly question with a probably quick an easy (or
maybe not so easy) answer that I can't seem to figure out.
I have a class method in one class. I want to pass this method to an
object of another class to use as a callback. I have the code at the
end of the message but it doesn't quite work. At runtime, it
produces the following error messages and the application exits due
to signal 5 (SIGTRAP):
*** -[foo aSelector:]: selector not recognized [self = 0x369670]
An uncaught exception was raised
*** -[foo aSelector:]: selector not recognized [self = 0x369670]
*** Uncaught exception: <NSInvalidArgumentException> *** -[foo
aSelector:]: selector not recognized [self = 0x369670]
Why is this happening? I am missing something terribly simple,
aren't I? I was able to get this to work by modifying the callback
to take an NSNumber* argument, then using performSelector:withObject
within but doSomething. But I am sure there must be another way to
do what I want.
Thanks for any help.
-- ivan
@implementation foo // a foo object is to be called back
...
- (void)callbackFunction:(int)x { /* define the callback */ }
...
// inside some other method
boo* b;
...
[b doSomething:self withCallBack:@selector( callbackFunction: )]
...
...
#end
@implementation boo
...
- (void)doSomething:(id)anObject withCallBack:(SEL)aSelector {
...
[anObject aSelector:10];
...
}
...
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden