是否可以在 iphone、ipod、ipad 和 mac 中运行 iphonic 应用程序? [英] Is it possible to run an iphonic application in iphone,ipod,ipad and mac?

查看:57
本文介绍了是否可以在 iphone、ipod、ipad 和 mac 中运行 iphonic 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以同时在 iphone 和 mac 上运行 iphone 应用程序.如果可能,你们可以建议我如何完成.

I want to know whether it is possible to run an iphonic application both in iphone and mac.If it is possible can you guys suggest me how it would be done.

我们将不胜感激任何人的帮助.

Anyone's help will be deeply appreciated.

推荐答案

Xcode 中有创建 Universal 应用程序的选项.但是,这仅涵盖 iDevices.如果您也希望为 MacOS 编译相同的代码,则需要通过插入预处理器条件来完成

There is the option in Xcode to create Universal apps. However, this will only cover iDevices. If you wish to compile the same code for MacOS as well you need to do it by inserting preprocessor conditionals

#ifdef TARGET_OS_MAC
  // we are on MacOS
#elif defined TARGET_OS_IPHONE
  // we are on iOS
#else
  // unknown platform
#endif

那是因为 Mac 和 iOS API 在某些方面是不同的(每个平台都有一些专门存在的类,例如 UIKit/AppKit)

That's because the Mac and iOS APIs are at some point different (there are some classes that exclusively exist for each platform, e.g. UIKit/AppKit)

这篇关于是否可以在 iphone、ipod、ipad 和 mac 中运行 iphonic 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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