您的位置:首页 > 移动开发 > Objective-C

What is the best way to port from Objective-C to C++?

2012-10-19 09:25 609 查看

What is the best way to port from Objective-C to C++?

I have no Objective-C experience whatsoever but have a strong C++ background. Is there an automated tool/script or, worst case, some manual method using some excellent reference to port code written in Objective-C to C++? What are the difficulties involved?

Edit:I'm told the code uses Objective-C fairly trivially. It's an iPhone app that probably doesn't use much in the way of OS-level UI. The C++ version is meant for a non-Apple platform where GNUStep is not an option, so Objective-C++ is not an option.



There are no automated tools that I'm aware of. The dynamic nature of Objective-C is very hard to translate to C++, so quite a bit of brain effort is going to be required for all but trivial Objective-C code. Are you willing to stay on OS X (or keep the
GNUStep dependency if you're one of the few people using Objective-C on an OS besides OS X)? If so, the easiest approach is to useObjective-C++
to build a bridge beteen the Objective-C and C++ code. Objective-C++ is an Apple extension to Objective-C and the GCC compiler that allows you to mix Objective-C and C++ code. You can thus create Objective-C objects that call or reference (but not inherit
from) C++ objects and you can send Objective-C messages to Objective-C instances from within C++ code.

I worked on same problem. And have some solutions:

In 2007 I tried support Objective-C in Visual Studio and write my own ObjC runtime, but I do not have more time for writing parser for it. If you have, you can :)

http://code.google.com/p/qobjc/

I write basic functionality of Foundation Framework written on C++, in this case need port manually, your code will be on C++ but it will be like on Objective-C. This library worked on iPhone.

http://code.google.com/p/dcocoa/

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐