Re: Mixing Obj-C and C "methods"
Re: Mixing Obj-C and C "methods"
- Subject: Re: Mixing Obj-C and C "methods"
- From: Michael Crawford <email@hidden>
- Date: Tue, 30 Jul 2013 08:26:00 +0000
I don't think so, not it if has a C-language prototype rather than an
Objective-C method prototype.
However, I expect there is a way you could call an Objective-C method
from vanilla C. Possibly you will need some assembly-language glue.
Ultimately, Objective-C method calls are implemented, I expect, as C
functions that have some "extra stuff" attached, for example to pass
in "self" as a hidden (first I think) parameter.
Try writing a small Objective-C method, that calls another one in the
same source file. Then in Xcode, use Product -> Generate Output ->
Assembly File to see how that first method calls the second.
You will need some way for your C callback to be told what "self" is.
Mike Crawford
email@hidden
http://www.warplife.com/
On Tue, Jul 30, 2013 at 7:59 AM, Vincent Habchi <email@hidden> wrote:
> Hi everybody,
>
> 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?
>
> Thanks a lot!
> Vincent
>
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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