在 iOS 和 Mac OS X 应用程序中使用 C++ [英] Utilizing C++ in iOS and Mac OS X applications

查看:45
本文介绍了在 iOS 和 Mac OS X 应用程序中使用 C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 C++ 知识有点中庸,但对 Objective-C 几乎一无所知.我正在计划(甚至开始)学习 Objective-C,这样我就可以尝试编写一些 iOS 甚至 Mac OS X 应用程序,但我对尚未找到的东西很好奇.

I'm somewhat moderate in my C++ knowledge but know next to nothing regarding Objective-C. I am planning (and even starting to) learn Objective-C so I can attempt to write a few iOS and even Mac OS X applications but I'm very curious about something I haven't been able to find yet.

是否可以完全使用 C++ 编写 iOS 和/或 Mac OS X 应用程序,包括 UI 组件?如果不可能完全用 C++ 来完成,那么在多大程度上可以主要使用 C++?

Is it possible to write an iOS and / or a Mac OS X application entirely with C++ including the UI components? If it isn't possible to do it entirely in C++ then to what degree is it possible to use mostly C++?

我还没有看到任何演示这些项目的示例.我计划为 iOS 和 Android 编写一些移动应用程序,并且在可能的情况下,我希望将我的大部分逻辑包含在 C++ 代码中,以实现最大的可移植性.我已经知道我可以做到这一点,但我不确定学位.

I haven't seen any examples that demonstrate either of these items. I am planning on writing a few mobile applications for iOS and Android and, where possible, I'd like to contain most of my logic inside of C++ code for maximum portability. I already know I can do this but I am unsure of the degree.

推荐答案

简短的回答,是的.

对于纯 C++,您应该查看 QT 框架.
否则,您将很难处理 UI 部分.

For pure C++, you should take a look at the QT framework.
Otherwise, you'll have hard time for the UI part.

但也要记住,Objective-C 可以与 C++ 混合使用.
这称为 Objective-C++(.mm 文件).

But also remember that Objective-C can be mixed with C++.
That's called Objective-C++ (.mm files).

然后您可以编写混合 C++ 和 Objective-C 代码的代码.有了这个,你可以在 Objective-C 中拥有 UI 部分(可能更好,因为它将使用原生框架作为 UI 组件),以及在 C++ 中的其他东西.

You can then write code that mix C++ and Objective-C code. With this, you can have the UI parts in Objective-C (may be better, as it will use the native frameworks for the UI components), and the other things in C++.

如果您决定学习 Objective-C,但仍想用 C++ 编写某些部分的代码,我会推荐这种方法,而不是纯 C++.

If you've decided to learn Objective-C, but still want to code in C++ for some parts, I would recommend this approach, instead of pure C++.

iOS 上,这也是唯一的方法.虽然您可以使用 C++ 进行编码,但您必须在 UI 部分使用 Objective-C.

On iOS, this is also the only way. While you can code in C++, you have to use Objective-C for the UI part.

编辑

以下是一些开始使用 Objective-C++ 的链接:

Here are a few links to get started with Objective-C++:

这篇关于在 iOS 和 Mac OS X 应用程序中使用 C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆