如何$ Android和iOS之间的C $Ç共享 [英] How to code sharing between Android and iOS

查看:141
本文介绍了如何$ Android和iOS之间的C $Ç共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从严格的Andr​​oid开发搬走,并希望创建iPhone应用程序。我的理解是,我可以code的iOS应用程序后端的C / C ++,也认为我可以使用NDK,包括C / C ++ code的Andr​​oid应用程序。然而,我的问题是怎么样?我GOOGLE了相当多的,我无法找到任何简洁明了的答案。 当看到样品code的NDK,似乎所有的函数名等是Android的(或至少是Java的)具体的,所以我将无法使用此C / C ++后端来开发一个iPhone前端? 我倒是AP preciate一些澄清这个问题,如果在所有可用的一些code来帮助我吗? (甚至只是一个简单的Hello World,从一个C / C ++文件中读取一个字符串,并在iOS和Android应用程序显示它)。

I'm moving away from strict Android development and wanting to create iPhone applications. My understanding is that I can code the backend of iOS applications in C/C++ and also that I can use the NDK to include C/C++ code in Android apps. My question however is how? I've googled quite a bit and I can't find any clear and concise answers. When looking at sample code for the NDK, it seems that all the function names etc. are Android (or at least Java) specific and so I would not be able to use this C/C++ backend to develop an iPhone frontend? I'd appreciate some clarification on this issue and if at all available some code to help me out? (even just a simple Hello World that reads a string from a C/C++ file and displays it in an iOS and Android app).

谢谢你们 克里斯

推荐答案

虽然情绪是合理的(你下面做不重复自己的政策),它只有务实的,如果你可以共享code在以有效的方式。在这种情况下,它不是真的有可能有一个写一次的方式来跨平台开发,其中需要code两个平台用不同的语言(C / C ++ /的OBJ-C在iPhone,Java进行Android的)。

While the sentiment is sound (you are following the policy of Don't Repeat Yourself), it's only pragmatic if what you can share that code in an efficient manner. In this case, it's not really possible to have a "write once" approach to cross-platform development where the code for two platforms needs to be written in different languages (C/C++/Obj-C on iPhone, Java for Android).

您会更好写两个不同的codebases在此情况下(在两种不同的语言)。字忠告:不要写你的Java code,喜欢它的C ++,或你的C ++ code像它的Java语言。我一数年前曾在一家公司谁了产品,他们移植从Java到C ++,他们没有写C ++ code就像是C ++,和它造成的种种问题,而不是何况是难以阅读。

You'll be better off writing two different codebases in this case (in two different languages). Word of advice: don't write your Java code like it's C++, or your C++ code like it's Java. I worked at a company a number of years ago who had a product they "ported" from Java to C++, and they didn't write the C++ code like it was C++, and it caused all sorts of problems, not to mention being hard to read.

这篇关于如何$ Android和iOS之间的C $Ç共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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