Access Obj-C method/attribute from a C method
Access Obj-C method/attribute from a C method
- Subject: Access Obj-C method/attribute from a C method
- From: Eric MORAND <email@hidden>
- Date: Sat, 7 Jul 2007 09:13:43 +0200
Hi list,
I was wondering it it was possible to call an Obj-C method or access
Obj-C instance attributes from inside a C method.
Let's say I have the following Obj-C class :
@interface FooBar : NSObject
{
NSMutableArray * fooArray;
}
- (void)addObjectToFooArray:(id)anObject;
@end
In my implementation, I have to use some C methods (because I'm
dealing with IOKit) and need to add some objects in fooArray from
inside my C method :
void ObjectAdded(void * refCon, io_iterator_t iterator)
{
// A lot of things are done...
[self addObjectToFooArray:anObject];
}
Unfortunately, it doesn't compile :
error: 'self' undeclared (first use in this function)
Is there a way to achieve what I need ?
Thanks,
Eric.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden