Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

floyde

macrumors 6502a
Original poster
Apr 7, 2005
808
1
Monterrey, México
I was writing an AppleScript manager class using this example (the one by BenoitMarchal). I basically needed a method that could call an AppleScript function with parameters. The author said that it was the way to do it with Cocoa, but he used some Carbon-only constants (ie kASAppleScriptSuite, kASSubroutineEvent, etc.). Since Cocoa doesn't seem to have those constants, I added the Carbon header in order to be able to compile the code under my Cocoa plugin.

Is this a bad practice? Could it cause any problems in the future? Should I be looking for the Cocoa equivalents? thanks
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
floyde said:
I was writing an AppleScript manager class using this example (the one by BenoitMarchal). I basically needed a method that could call an AppleScript function with parameters. The author said that it was the way to do it with Cocoa, but he used some Carbon-only constants (ie kASAppleScriptSuite, kASSubroutineEvent, etc.). Since Cocoa doesn't seem to have those constants, I added the Carbon header in order to be able to compile the code under my Cocoa plugin.

Is this a bad practice? Could it cause any problems in the future? Should I be looking for the Cocoa equivalents? thanks

I don't know if there's a Cocoa equivalent, but there's nothing wrong with mixing Carbon and Cocoa. A lot of times Carbon is still the only way to get something done. And you did it the right way, too: include the header and link against the library. Just because you link against it doesn't mean it copies all the Carbon APIs into your app and bloats it or slows it down or anything like that, so don't sweat it.
 

floyde

macrumors 6502a
Original poster
Apr 7, 2005
808
1
Monterrey, México
savar said:
And you did it the right way, too: include the header and link against the library.
Mmm... I think I only included the header but I didn't link against the library :eek: (if that means that it should appear under the "Linked Frameworks" section of the project window). Should I link it as well? thx
 

GeeYouEye

macrumors 68000
Dec 9, 2001
1,669
10
State of Denial
Yes.

And I'll reiterate that there's nothing wrong with using Carbon in Cocoa, or Cocoa in Carbon. They're two different API's, each with their own uses. They can be mixed without issue.

EDIT: although I think you may be incorrect about there not being a Cocoa equivalent for what you're looking for.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.