Qt/Objective-C Bridge
There are a lot of cross-platform frameworks, the best one in my opinion is Qt from Trolltech
(now Qt Software).
It supports C++ and Java as programming languages for writing Qt based applications.
I am programming on the Mac OS X since 2004 using C++ and Objective-C with Cocoa and Carbon as frameworks. From Mac OS X 10.5 (Leopard) on, Apple tries to move their every app to Cocoa and encourages others to do it, yet carbon is still available.
I always wanted to write cross-platform apps, but do it just on the Mac and deploy them to other systems and yes Qt opens this way with C++ and Java (I will not talk about Java), but there’s one thing to note: developers working for a long time with Objective-C and Cocoa, need to learn a new (may be not new, because C++ is derived from C like Objective-C is) language or at least have to be a mid-level, to develop Qt applications. And I decided to write a bridge to Qt, so that Objective-C developers would be able to use the same Qt power, the same API, just learning the Qt API and nothing more.
Here is a code example of a simple Qt Application using C++
1 2 3 4 5 6 7 8 9 | #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("Hello world"); label->show(); return app.exec(); } |
It does not do any special, useful thing, just display a small window and a label in it.
Below you see the same code but rewritten in Objective-C:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #import <QApplication> #import <QLabel> int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; QApplication *theApp = [[QApplication alloc] initWithArgc:argc andArgv:argv]; QLabel *label = [[QLabel alloc] initWithLabel:@"Hello world"]; [label show]; [theApp exec]; [label release]; [theApp release]; [pool drain]; return 0; } |
As you see, it is plain Objective-C code. Those who didn’t write a line of Objective-C code, would say: for what you need this bridge, C++ is very powerful language. What can I say? I belive that C++ is great, I work myself with it, but there’s a lot of bridges to Qt, like PyQt, PHPQt etc. I would be very glad to have an Objective-C bridge too.
This will be an opensource project, so anyone will be able to download the code, for now, no code is available for download, after getting at least 20% of Qt API ready for use, I will publish it to you.