• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Access Obj-C method/attribute from a C method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Access Obj-C method/attribute from a C method
      • From: Alastair Houghton <email@hidden>
    • Re: Access Obj-C method/attribute from a C method
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Re: Adding metadata to images
  • Next by Date: Re: Mounting Local Volumes
  • Previous by thread: Re: Composite NSImage as Core Data transient attribute
  • Next by thread: Re: Access Obj-C method/attribute from a C method
  • Index(es):
    • Date
    • Thread