Re: How to define a method IMP for use as a C callback?
Re: How to define a method IMP for use as a C callback?
- Subject: Re: How to define a method IMP for use as a C callback?
- From: John Randolph <email@hidden>
- Date: Tue, 23 Mar 2004 13:03:27 -0800
Why not just define a function in your .m that invokes the method in
question?
eg:
- (void) handleNotification:(ICARegisterEventNotificationPB *) inPB
{
NSLog(@"entered handleNotification method %@", inPB);
// I get to here, but "inPB" is always NULL
}
@end
void handleNotification(ICARegisterEventNotificationPB *inPB)
{
[whateverObject handleNotification: inPB];
}
On Mar 23, 2004, at 12:59 AM, Ken Tozier wrote:
I'm working with the ICA architecture and need to define an IMP for one
of my methods so it can be called as a C function by the ICA runtime. I
got it to the point where it does enter the method, when a camera is
plugged in, but the passed in parameter is always NULL. I'm sure I'm
just making a syntax error but can't figure it out. Could someone point
out what I'm doing wrong?
In my installNotification, the IMP is defined as follows:
- (void) installNotification
{
ICARegisterEventNotificationPB pb = {};
// create an IMP so the ICA architecture can call "handleNotification"
as a C function
typedef void (*HandleMessageIMP)(id, SEL,
ICARegisterEventNotificationPB *);
HandleMessageIMP doHandleMessage = (HandleMessageIMP)[self
methodForSelector:@selector(handleNotification:)];
// init the param block
pb.object = 0; // all objects
pb.notifyType = 0; // all types
pb.notifyProc = (ICACompletion) doHandleMessage;
// register handleNotification with the ICA architecture
if (ICARegisterEventNotification(&pb, NULL) == noErr);
{
NSLog(@"notification callback registered");
}
}
The "handleNotification method is...
- (void) handleNotification:(ICARegisterEventNotificationPB *) inPB
{
NSLog(@"entered handleNotification method %@", inPB);
// I get to here, but "inPB" is always NULL
}
Thanks
Ken
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.