How to define a method IMP for use as a C callback?
How to define a method IMP for use as a C callback?
- Subject: How to define a method IMP for use as a C callback?
- From: Ken Tozier <email@hidden>
- Date: Tue, 23 Mar 2004 03:59:19 -0500
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.