使用 Objective-C 进行 Windows 开发 [英] Windows development using Objective-C

查看:75
本文介绍了使用 Objective-C 进行 Windows 开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近阅读了一篇关于 Objective-C 的文章,我觉得它是一种相当简洁的语言,具有许多很酷的功能.

Having recently read up a on Objective-C it strikes me as a fairly neat language with plenty of cool features.

我无意进行任何 iPhone 开发,但是我知道 GCC 能够编译 Objective-C 代码,所以我想知道 - Objective-C 是否是 C99 的可行替代语言,用于 Windows 开发?

I have no intention of doing any iPhone development, however I understand that GCC is able to compile Objective-C code and so I wanted to know - Is Objective-C a viable alternative language to C99 for Windows development?

特别是:

  • 目前是否有人使用 Objective-C 进行 Windows 开发?
  • 是否有任何运行时组件需要与我的应用程序一起分发?
  • 我知道 Objective-C 是 C 的超集,这是否意味着可以使用任何与 C 兼容的库?(例如 Windows API)
  • 我的应用程序是否会进行垃圾回收?
  • 我找到了 CocotronGNUstep 在谈论在其他平台上使用 Objective-C 时经常被提及,但是由于 GCC 已经可以用于编译 Objective-C 我真的不明白为什么我需要这些.
  • 在尝试使用 Objective-C 进行 Windows 开发时,我是否会遇到其他任何陷阱或陷阱?
  • Is anyone currently doing Windows development using Objective-C?
  • Are there any runtime components that would need to be distributed with my applications?
  • I understand that Objective-C is a superset of C, does this mean that it is possible to use any C-compatible library? (for example the Windows API)
  • Would I get garbage collection in my applications?
  • I've found Cocotron and GNUstep which are often mentioned when talking about using Objective-C on other platforms, however as GCC can already be used to compile Objective-C I don't really understand why I would need these.
  • Are there any other pitfalls or traps I might run in attempting Windows development using Objective-C?

推荐答案

关于你的第一个问题,我不知道有没有人认真用 Objective-C 在 windows 上做开发,但是可能有,尽管这些数字可能比那些使用 whitespace 之类的语言认真工作的人数少>.

With respect to your first question, I don't know if anyone is seriously doing development on windows with Objective-C, but there may be, though those numbers would probably be less than those doing serious work with a language like whitespace.

其次,您至少需要 Objective-c 运行时.有两个运行时,NeXT(现在是 Apple 的)运行时和 GNU Objective-C 运行时.它们不兼容.如果您使用的是非 NeXT 和非 Apple 平台,例如 windows,则您别无选择,只有 GNU 运行时.

Secondly, you would need, at a minimum the objective-c runtime. There are two runtimes, NeXT's (now Apple's) runtime, and the GNU Objective-C runtime. They are not compatible. If you are on a non-NeXT and non-Apple platform, such as windows, you have no choice, GNU runtime only.

Objective-C 是 C 的超集,是的,如果您愿意,可以直接在 Objective-C 代码中使用 Win32 API.同样,如果您使用保守的收集器,您只会获得垃圾收集,并且它与您正在使用的库相关联.简而言之:没有.

Objective-C is a superset of C, and yes you can use the Win32 API if you so desire directly in your objective-c code. As well, you would only get garbage collection if you use a conservative collector, and it ties in with the libraries you're using. In short: No.

GCC 支持 Objective-C 语言和运行时,没有标准库.就标准库而言,GNU objc 运行时为您提供的是两个对象:Object 和支持 @"" 语法所需的 NXConstantString 类.Object 只是一个基类.不是很有用,嗯?这就是 Cocotron 和 GNUstep 等框架存在的原因——让您可以访问 OPENSTEP/Cocoa 的实现.

What GCC has is support for the objective-c language, and runtime, no standard library. What the GNU objc runtime provides you with in terms of a standard library, is two objects: Object, and NXConstantString class, which is needed to support the @"" syntax. Object is merely a base class. Not very useful, eh? This is why frameworks like Cocotron and GNUstep exist — to give you access to an implementation of OPENSTEP/Cocoa.

关于陷阱或陷阱,是的:例如,您的应用程序,即使使用 Cocotron 或 GNUstep 也可能永远无法移植到 Mac,或者您可能会被 GNU objc 运行时中的类型选择器之类的东西所困扰,或者过多的其他问题.让我通过提出另一个问题来回答这个问题:针对 .NET,您可能会遇到哪些陷阱?我敢肯定,有些(如果不是大多数)也适用于这种情况.标准陷阱和陷阱适用.

Regarding pitfalls or traps, yeah: Your application, even using Cocotron or GNUstep may never be portable to the Mac for instance, or you may get bit by things like typed selectors in the GNU objc runtime, or a plethora of other problems. Let me finish answering this by posing another question: What pitfalls or traps might you run into targeting .NET? I'm sure some if not most of those apply in this case too. Standard pitfalls and traps apply.

我希望这会有所帮助.

这篇关于使用 Objective-C 进行 Windows 开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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