有没有办法混合使用 MonoTouch 和 Objective-C? [英] Is there a way to mix MonoTouch and Objective-C?

查看:25
本文介绍了有没有办法混合使用 MonoTouch 和 Objective-C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法在一个项目中混合 C# 和 Obj-C 代码.具体来说,我想在 Obj-C 中为我的 UI 使用 Cocos2D,并调用一些 MonoTouch C#-Library 来执行一些计算并返回一些值.有没有办法做到这一点?或者反过来,我.e.在 MonoTouch 中构建并调用 Cocos2D 函数?谢谢.

I'd like to know if there is a way to mix C# and Obj-C code in one project. Specifically, I'd like to use Cocos2D for my UI in Obj-C and call some MonoTouch C#-Library that does some computations and get some values back. Is there a way to do this? Or maybe the other way around, i. e. building in MonoTouch and calling Cocos2D-functions? Thanks.

推荐答案

您描述的设置是可能的,但是管道并不像您在 MonoTouch 中完成整个项目时那样顺畅.这实际上是我们引导 MonoTouch 的方式:我们采用了一个现有的 Objective-C 示例,然后我们用托管代码一一替换了这些位.

The setup that you describe is possible, but the pipeline is not as smooth as it is when you do your entire project in MonoTouch. This is in fact how we bootstrapped MonoTouch: we took an existing Objective-C sample and we then replaced the bits one by one with managed code.

我们丢弃了这些样本,因为它们会腐烂.

We dropped those samples as they bitrot.

但是您仍然可以完成此操作,使用 mtouch 的 --xcode 命令行选项为您生成示例程序,然后将您想要的位从生成的 template.m 中复制到您的 main.m 中.自定义您想要的组件,然后从那里启动 XCode 项目.

But you can still get this done, use the mtouch's --xcode command line option to generate a sample program for you, and then copy the bits that you want from the generated template.m into your main.m. Customize the components that you want, and just start the XCode project from there.

在您的开发周期中,您将继续使用 mtouch --xcode

During your development cycle, you will continue to use mtouch --xcode

这篇关于有没有办法混合使用 MonoTouch 和 Objective-C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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