On Jul 30, 2013, at 00:59 , Vincent Habchi <vi...@macports.org> wrote:
> I have a very simple question: if I embed a C-function (more precisely, a > callback from an external C-library) in an Obj-C object, can I expect this > function to behave like a regular method? I.e. can it freely access ‘self’ > and other attributes? No; it'll be a stand-alone method with no implicit knowledge of the Objective-C class. Having said that, most callback APIs allow you to pass a context parameter that gets passed back to your C callback. Often times, this context parameter is a void* you pass in along with a pointer to your callback function. You can pass "self" in this parameter when you register the callback, then cast it inside your callback back to MyClass* (or whatever your class is. Precisely how you do this depends on the API you're using. If it's a non-Apple API, it's much more likely they did it wrong and did not provide a context parameter. What API are you using? -- Rick _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com