简体   繁体   English

Mac OS X开发的替代范例

[英]Alternative paradigm for Mac OS X development

The current standard way of developing Mac OS X apps is with XCode/Objective-C/Interface Builder using the MVC paradigm. 开发Mac OS X应用程序的当前标准方法是使用MCode范例使用XCode / Objective-C / Interface Builder。

Is there an alternative? 还有其他选择吗?

I'd like to use Interface Builder (XCode too) however I would rather use a different programming language. 我想使用Interface Builder(也是XCode),但是我宁愿使用其他编程语言。 I come from .NET programming where you can delegate a click to a certain function, etc.. Is there something like that for Mac? 我来自.NET编程,您可以在其中将单击委派给某个功能,等等。Mac是否有类似的东西? I would rather stay away from bootstrapped apps like Titanium or Qt or RealBASIC. 我宁愿远离诸如Titanium或Qt或RealBASIC之类的自举应用程序。

Objective-c is very powerful and together with Cocoa and Interface Builder allow you to develop UI on Mac OS X. Objective-c非常强大,并且与Cocoa和Interface Builder一起使您可以在Mac OS X上开发UI。

You can associate target in UI with action in code that gets executed and so on. 您可以将UI中的目标与已执行代码中的动作相关联,依此类推。

You can check out IB guide , connections and bindings and Introduction to Cocoa Application Tutorial which builds example application (check out the Bridging the Model and View: The Controller section for how UI elements get hooked up to code) - that is if you are interested in Objective-c/Cocoa. 您可以查看IB指南连接和绑定,以及构建示例应用程序的Cocoa Application Tutorial简介 (请查阅“ 桥接模型和视图:控制器”部分,了解如何将UI元素链接到代码)-如果您感兴趣的话在Objective-c /可可中。

You can already assign clicks to methods in Objective-C - you define a method with a return type of IBAction and you can wire that to a number of possible events in a button, or many other controls for that matter. 您已经可以在Objective-C中为方法分配点击-您使用IBAction的返回类型定义方法,并且可以将其关联到按钮中的许多可能事件或与此相关的许多其他控件。

Learn to use the tools before you decide to wander off to other languages, because there is a lot of depth here from decades of evolution. 在您决定过渡到其他语言之前,请先学习使用这些工具,因为数十年来的发展具有深远的意义。

There are so many of these questions on SO. 关于SO的问题很多。 Especially in the mac/iphone tags. 特别是在mac / iphone标签中。 Someone posts asking how to make mac/iphone development more like some IDE/paradigm they already know. 有人发帖询问如何使Mac / iphone开发更像他们已经知道的某些IDE /范例。

Mac development is different from C#, .NET, etc. It is not less powerful, it's just different. Mac开发与C#、. NET等不同。它的功能同样强大,只是有所不同。 Cocoa has many strengths which might not be apparent when you are trying to apply your old way of thinking. 可可具有许多长处,当您尝试应用旧的思维方式时可能并不明显。

Not to diss any of projects mentioned here (PyObjC, MacRuby, etc.) but they are going to be just as confusing, because they are a thin (and leaky) abstraction layer over the native developer tools. 不要讨论这里提到的任何项目(PyObjC,MacRuby等),但它们将同样令人困惑,因为它们是本机开发人员工具上的一个薄薄(且泄漏)的抽象层。

If you're going to develop on the Mac, take some time and learn Objective-C/Cocoa/Xcode/IB. 如果要在Mac上进行开发,请花一些时间并学习Objective-C / Cocoa / Xcode / IB。 It's not the way you know, but it's a good way if you give it a chance. 这不是您所知道的方式,但是如果您有机会的话,这是一个好方法。 Once you know it you will have criticisms still, but you will also have undoubtedly found things you really like about it. 一旦知道了它,您仍然会受到批评,但是毫无疑问,您还将找到您真正喜欢它的东西。

If you don't like to learn new platforms/paradigms/environments learn java or qt once and be done with it. 如果您不喜欢学习新的平台/范式/环境,请学习一次Java或Qt并完成它。

Depending on your language experience, and target requirements you might find MacRuby very interesting. 根据您的语言经验和目标要求,您可能会发现MacRuby非常有趣。

There is also PyObjC and a older ruby bridge named RubyCocoa . 也有PyObjC并命名为旧的红宝石桥RubyCocoa

However, if you're looking for iphone development, the only thing I've heard about is MonoTouch from Novell, and requires licensing fees. 但是,如果您正在寻找iphone开发,我听说的唯一的就是Novell的MonoTouch ,它需要付费使用。

Please note that all of the above techs allow pretty seamless integration with both their native language libraries as well as the libraries and frameworks found in Cocoa and Carbon. 请注意,上述所有技术都允许与其本地语言库以及Cocoa和Carbon中的库和框架进行无缝集成。

Using these techs will give you a fairly clean native feeling app. 使用这些技术将为您提供一个相当干净的原生感觉应用程序。 However, many if not all will still require you to use Interface Builder. 但是,许多(如果不是全部)仍然需要您使用Interface Builder。 Which I know took me a while to get used to too. 我知道我花了一段时间也习惯了。

There are lots of bridges. 有很多桥。 PyObjC, CamelBones (Perl), JSCocoa (JavaScript), Cocoa#, HOC (Haskell), etc. The only one that's really even close to seamless is MacRuby, a Ruby implementation on top of core Mac OS X technologies like LLVM and the Objective-C runtime and garbage collector that's designed to be a peer language to Objective-C for Cocoa development. PyObjC,CamelBones(Perl),JSCocoa(JavaScript),Cocoa#,HOC(Haskell)等。唯一真正接近无缝的是MacRuby,它是在LLVM和Objective等核心Mac OS X技术之上的Ruby实现。 -C运行时和垃圾收集器,被设计为用于Cocoa开发的Objective-C的对等语言。 It's still in beta, though. 不过,它仍处于测试阶段。 It does let you assign a Ruby block as the action handler for UI elements, which I gather is something you like doing. 它确实允许您将Ruby块分配为UI元素的动作处理程序,我喜欢这样做。

It's hard to say whether you prefer elaboration on language or design patterns. 很难说您是喜欢语言还是设计模式。

See Objective-C++, Python, or Ruby (the java bridge is deprecated). 请参阅Objective-C ++,Python或Ruby(不建议使用Java桥)。 Remember that ObjC is a superset of C, you can use C, C++ and ObjC in the same app/sources. 请记住,ObjC是C的超集,您可以在同一应用程序/源中使用C,C ++和ObjC。 Soo... you may be most comfortable using Objective-C++. 太...您可能最喜欢使用Objective-C ++。 It sounds like a hybrid object, but it is merely support for the objects and syntaxes in the same program (ie you do not base a ObjC class on a C++ class, but you can use members). 听起来像是一个混合对象,但它仅支持同一程序中的对象和语法(即,您不是将ObjC类基于C ++类,而是可以使用成员)。 This is a big topic, actually, though I've never seen writings on it beyond a few pages. 实际上,这是一个很大的话题,尽管我只看过几页,却从未见过有关它的著作。

As far as design patterns, well, you're the programmer :) 就设计模式而言,您是程序员:)

Your best bet, would be to use Cocoa Sharp support for winforms. 最好的选择是对Winform使用Cocoa Sharp支持。 There are some tutorials on the cocoasharp site. 在cocoasharp网站上有一些教程。 That would give you a head start, but I'm afraid you won't get very far with this approach, Cocoa is not really suited to that approach and in the end, code would end up difficult to manage. 这将为您提供一个良好的开端,但恐怕您对这种方法不会走得太远,Cocoa并不真正适合该方法,最终,代码将最终难以管理。

What you can do, if you don't mind the Cocoa conventions but are not really into Objective-C, is to use Cocoa Sharp (ie, C#) to code using Cocoa's MVC paradigm. 如果您不介意Cocoa约定但不真正了解Objective-C,则可以使用Cocoa Sharp(即C#)通过Cocoa的MVC范例进行编码。 That way, you still get to use Interface Builder (I'm not so sure of XCode support in Snow Leopard) and use a familiar language. 这样,您仍然可以使用Interface Builder(我不确定Snow Leopard是否支持XCode)并使用一种熟悉的语言。

Looks like this approach is productive, as people are even doing iPhone applications that way. 看起来这种方法很有成效,因为人们甚至都以这种方式来做iPhone应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM