PDA

View Full Version : Hook up C++ code to user interface?




TheReef
Feb 10, 2009, 03:54 AM
Hi all,
I am trying to get C++ talking to a user interface.

Is there something similar to what I'd do with Cocoa:
1) Make application controller class in Interface Builder.
2) Add actions and outlets.
3) Write class files back to project.


I looked here (http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_tasks/chapter_3_section_3.html#//apple_ref/doc/uid/TP30001004-CH206-BCIIEDHF) and it seams I need to use the Carbon Events Manager, I'm totally lost there.

I have selected Carbon C++ application from Xcode but opening the .xib file in Interface Builder I can't seam to create a class, and from there add the actions and outlets.

Any suggestions would be great!
Thanks :)



MacRumors Guy
Feb 10, 2009, 04:22 AM
Use Objective-C++ with Cocoa, wrapping your backend code in Objective-C++ controllers.

TheReef
Feb 12, 2009, 04:59 AM
Thanks, I did some research into Objective-C++, as I'll still need to be using Objective-C I've decided may as well get into learning it.

Everything about it looks so confusing compared to C++ :(
The whole square bracket notation and way classes are defined and used looks very different.

MacRumors Guy
Feb 12, 2009, 06:40 AM
I hope you learn to appreciate the sexiness and the simplicity of Objective-C ;).

This site (http://sigpipe.macromates.com/) might help you a bit about how to interop between C++ and Objective-C.

Krevnik
Feb 12, 2009, 10:10 AM
Thanks, I did some research into Objective-C++, as I'll still need to be using Objective-C I've decided may as well get into learning it.

Everything about it looks so confusing compared to C++ :(
The whole square bracket notation and way classes are defined and used looks very different.

If you managed to pick up C++, Objective-C won't be too bad. There are some behavioral differences, and the frameworks are totally different. But the rest? That is just syntax. Syntax is the easiest hurdle (in my experience) to overcome.

What will really cause the problems is getting out of the mindset of how you build classes in C++, and how you handle memory. You just don't do it the same way in Objective-C, and that is not a bad thing. If you let the rules and common practices of the language and frameworks sink in, you will do just fine I think.