Re: Interfacing cocoa/obj-c within a C plug-in API
Re: Interfacing cocoa/obj-c within a C plug-in API
- Subject: Re: Interfacing cocoa/obj-c within a C plug-in API
- From: Graham Cox <email@hidden>
- Date: Tue, 22 Dec 2009 20:56:34 +1100
On 22/12/2009, at 10:22 AM, Rich E wrote:
> Hi,
>
> I am new to Cocoa and Objective-C both, but I need the two in order to get
> tablet functionality into one of my favorite applications (Puredata) on Mac
> OS X. First off, I know that you can get tablet event data through the
> Carbon API, but I have ran into enough problems (along with no 64-bit
> support) that I think trying it with Cocoa is worth a shot. Puredata has an
> API for writing plug-in's in C and I hear that it is possible to write the
> entire plug-in in Obj-C but leave the host callback functions in standard C,
> yet I still don't understand how to embark.
>
> I learn best by examples, does anyone know of any existing C applications
> that make use of Cocoa or Objective-C? Else, any advice on how to combine
> these two with a host written in C?
The Carbon Event stuff is available in 64-bit, as far as I'm aware. Cocoa is built on it, so these lower-level parts of Carbon are very likely to remain available in 64-bit. It's mostly the higher level stuff, such as UI and legacy managers that are unavailable.
Objective-C is a strict superset of C, so it may be freely intermixed with C code with few special considerations. Source files containing any Objective-C would end in .m, whereas pure C would end in .c, but you can put whatever C code you want into a .m file and it will be compiled as you'd expect. So for a plug-in with a pure C application interface that can remain as normal, but if you want to call Obj-C methods internally just make the source files .m instead and link against the usual Cocoa frameworks, and it should work.
--Graham
_______________________________________________
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