Hi all,
I have been thinking of how to use cocoa in a pd external and I could use some advice. It has to be in Objective-C of course, and I see that gridflow uses cocoa a little (format/quartz.m). Still, I am not understanding how to combine the elements of a pd external (in C) with that of what I am finding in cocoa example applications (in objective-c). Will I just write the entire external in objective-c, or is there some specific way to use obj-c syntax within a C source file? Any tips or directs are thankfully welcomed.
regards, rich
Rich E wrote:
Hi all,
I have been thinking of how to use cocoa in a pd external and I could use some advice. It has to be in Objective-C of course, and I see that gridflow uses cocoa a little (format/quartz.m). Still, I am not understanding how to combine the elements of a pd external (in C) with that of what I am finding in cocoa example applications (in objective-c). Will I just write the entire external in objective-c, or is there some specific way to use obj-c syntax within a C source file? Any tips or directs are thankfully welcomed.
you can mix C-code and ObjC-code just fine in your .m file (that is: you can use C in ObjC; you cannot use ObjC in your C)
so basically you write everything in ObjC, but the callback-functions for Pd (which are written in C) i guess there are more elegant ways to do it, but this is how i would do it.
fgmasdr IOhannes
Thanks for the advice. I am not sure I understand how to get the callback functions for pd to interface with the cocoa API, but I'll give a crack at it later tonight and see how far I get (first time doing anything in obj-c). For me, I don't really care about elegance as much as that it will do everything that I want it to do (and fast).
Rich
On Mon, Dec 21, 2009 at 9:54 AM, IOhannes m zmoelnig zmoelnig@iem.atwrote:
Rich E wrote:
Hi all,
I have been thinking of how to use cocoa in a pd external and I could use some advice. It has to be in Objective-C of course, and I see that
gridflow
uses cocoa a little (format/quartz.m). Still, I am not understanding how
to
combine the elements of a pd external (in C) with that of what I am
finding
in cocoa example applications (in objective-c). Will I just write the entire external in objective-c, or is there some specific way to use
obj-c
syntax within a C source file? Any tips or directs are thankfully
welcomed.
you can mix C-code and ObjC-code just fine in your .m file (that is: you can use C in ObjC; you cannot use ObjC in your C)
so basically you write everything in ObjC, but the callback-functions for Pd (which are written in C) i guess there are more elegant ways to do it, but this is how i would do it.
fgmasdr IOhannes
Hmmm, after hearing back from the Cocoa-dev mailing list that all of Cocoa's Event handling code is based on Carbon (and is 64-bit compatible, at least the Event Handling), I don't know if it is worth it to write the external in ObjC (which I will probably do poorly at that, as it is my first attempt with the language). Anyways, Carbon is written in C, the WinTab API is written in C, so introducing ObjC may turn out to be a hassle later on instead of allowing future compatibility?
Well, thanks for the advice anyways.
On Mon, Dec 21, 2009 at 6:59 PM, Rich E rich.eakin@gmail.com wrote:
Thanks for the advice. I am not sure I understand how to get the callback functions for pd to interface with the cocoa API, but I'll give a crack at it later tonight and see how far I get (first time doing anything in obj-c). For me, I don't really care about elegance as much as that it will do everything that I want it to do (and fast).
Rich
On Mon, Dec 21, 2009 at 9:54 AM, IOhannes m zmoelnig zmoelnig@iem.atwrote:
Rich E wrote:
Hi all,
I have been thinking of how to use cocoa in a pd external and I could
use
some advice. It has to be in Objective-C of course, and I see that
gridflow
uses cocoa a little (format/quartz.m). Still, I am not understanding how
to
combine the elements of a pd external (in C) with that of what I am
finding
in cocoa example applications (in objective-c). Will I just write the entire external in objective-c, or is there some specific way to use
obj-c
syntax within a C source file? Any tips or directs are thankfully
welcomed.
you can mix C-code and ObjC-code just fine in your .m file (that is: you can use C in ObjC; you cannot use ObjC in your C)
so basically you write everything in ObjC, but the callback-functions for Pd (which are written in C) i guess there are more elegant ways to do it, but this is how i would do it.
fgmasdr IOhannes
Rich E wrote:
Hmmm, after hearing back from the Cocoa-dev mailing list that all of Cocoa's Event handling code is based on Carbon (and is 64-bit compatible, at least the Event Handling), I don't know if it is worth it to write the external in ObjC (which I will probably do poorly at that, as it is my first attempt with the language). Anyways, Carbon is written in C, the WinTab API is written in C, so introducing ObjC may turn out to be a hassle later on instead of allowing future compatibility?
?? just because cocoa uses carbon as a backend for event handling this shouldn't scare you away from using ObjC. most low-level runtime libraries, are written in C - but it still makes sense to use a higher language (if it makes sense) to use them.
ObjC is mostly a macOS thing; cocoa/carbon is obviously macos only. if you want crossplatform, then you shouldn't use it. if you want "native" macos support, it's a good choice (imho).
learning a new language can still be fun.
fg,arsd IOhannes
I was running along the lines that if Cocoa uses Carbon to handle events, and Cocoa is not usable on any other platform, why not use Carbon directly, as the Wacom guys provide examples for using both. It is not that I am scared of ObjC, it is having to base the entire external in ObjC and then it has to be completely rewritten for all other platforms.
I think the only real motivation I had behind using Cocoa was to learn it, along with ObjC. I thought compatibility would be another reason, but I am not so sure any more.
Another related question for those more experienced then myself: can I have the base of the external in C, then call methods from another source file containing the Cocoa API in ObjC?
2009/12/23 IOhannes zmölnig zmoelnig@iem.at
Rich E wrote:
Hmmm, after hearing back from the Cocoa-dev mailing list that all of
Cocoa's
Event handling code is based on Carbon (and is 64-bit compatible, at
least
the Event Handling), I don't know if it is worth it to write the external
in
ObjC (which I will probably do poorly at that, as it is my first attempt with the language). Anyways, Carbon is written in C, the WinTab API is written in C, so introducing ObjC may turn out to be a hassle later on instead of allowing future compatibility?
?? just because cocoa uses carbon as a backend for event handling this shouldn't scare you away from using ObjC. most low-level runtime libraries, are written in C - but it still makes sense to use a higher language (if it makes sense) to use them.
ObjC is mostly a macOS thing; cocoa/carbon is obviously macos only. if you want crossplatform, then you shouldn't use it. if you want "native" macos support, it's a good choice (imho).
learning a new language can still be fun.
fg,arsd IOhannes