Windows 上的 Cocoa 编程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2049099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cocoa Programming on Windows
提问by SVA
Is there a way to develop windows applications using cocoa and objective-c in general
有没有办法使用 Cocoa 和 Objective-c 来开发 Windows 应用程序?
回答by Quinn Taylor
To be clear, Objective-C is to Cocoa as C# is to .NET, or even as the Java language is to the Java platform — it's the primary way of doing things. Objective-C can be used wherever the compiler supports it, but the Cocoa frameworks are really the most valuable part of the equation.
需要明确的是,Objective-C 之于 Cocoa,就像 C# 之于 .NET,甚至就像 Java 语言之于 Java 平台一样——这是做事的主要方式。Objective-C 可以在编译器支持的任何地方使用,但 Cocoa 框架确实是等式中最有价值的部分。
One should also note that (os OS X) Safari is a Cocoa app, but iTunes is not yet (it still uses the legacy Carbon APIs) so I'm not sure how it is on Windows. Apple has ported some significant parts of Cocoa to Windows DLL's to port Safari, but to my knowledge, that code is not available for public consumption. (One can imagine that Apple doesn't really want to make it easy to create robust apps for a competing OS, they have only published two key apps to further their own goals, like adoption of iPod/iTunes and the WebKit browser core.) Don't expect to see these Cococa-Windows libraries become widely available; if they do, it will be a surprise to many of us.
还应该注意的是,(OS X) Safari 是一个 Cocoa 应用程序,但 iTunes 还不是(它仍然使用传统的 Carbon API)所以我不确定它在 Windows 上的情况。Apple 已将 Cocoa 的一些重要部分移植到 Windows DLL 以移植 Safari,但据我所知,该代码不可用于公共消费。(可以想象,Apple 并不真的想让为竞争操作系统轻松创建强大的应用程序,他们只发布了两个关键应用程序来实现自己的目标,例如采用 iPod/iTunes 和 WebKit 浏览器核心。)不要期望看到这些 Cococa-Windows 库变得广泛可用;如果他们这样做,我们很多人都会感到惊讶。
As @Gregory mentioned, GNUStep and Cocotron are plausible options to explore, but I'd suggest thinking long and hard about whether you really should do what you're asking. By and large, Microsoft's tools have much better support for Windows, you'll run into fewer undocumented limitations, and their native apps will tend to "feel right" to Windows users. I learned some time back that although I loveObjective-C/Cocoa, if I ever hadto write a Windows program, I would do it with the C#/.NET platform.
正如@Gregory 所提到的,GNUStep 和 Cocotron 是值得探索的合理选择,但我建议您仔细思考您是否真的应该按照您的要求去做。总的来说,微软的工具对 Windows 有更好的支持,你会遇到更少的未记录限制,而且他们的原生应用程序对 Windows 用户来说往往“感觉合适”。前段时间我了解到,虽然我喜欢Objective-C/Cocoa,但如果我不得不编写 Windows 程序,我会使用 C#/.NET 平台来完成。