在今天的一个本地。net活动上,Mono的使用被“提及”为iPhone开发的替代方案。在c#和。net中非常舒适,这似乎是一个有吸引力的选择,尽管Mono堆栈有一些奇怪的地方。然而,由于MonoTouch的售价为400美元,我有些纠结于这是否是iPhone开发的发展方向。

有人用MonoTouch和Objective-C开发过吗?如果是的话,用MonoTouch开发比学习Objective-C更简单、更快,而且值得花400美元吗?


当前回答

作为一个同时拥有c#和Objective-C经验的人,我想说对于大多数人来说Xamarin是物有所值的。

c#是一门设计得很好的语言,c# API也是设计得很好的。当然Cocoa Touch的API(包括UIKit)也有很好的设计,但是语言可以在几个方面得到改进。当你用c#写代码时,你可能会比用Objective-C写相同的代码更有效率。这是由于几个原因,但其中一些原因是:

C# has type inference. Type inference makes writing code quicker, since you don't have to "know" the type on the left-hand side of an assignment. It also makes refactoring easier and more saver. C# has generics, which will reduce errors compared to equivalent Objective-C code (though there are some work-arounds in Objective-C, in most situations developers will avoid them). Recently Xamarin added support for Async / Await, which makes writing asynchronous code very easy. You'll be able to reuse part of the code base on iOS, Android and Windows Phone. MonoTouch largely implements the CocoaTouch API's in a very straightforward way. E.g.: if you've got experience with CocoaTouch, you'll know where to find classes for controls in MonoTouch (MonoTouch.UIKit contains classes for UIButton, UIView, UINavigationController, etc..., likewise MonoTouch.Foundation got classes for NSString, NSData, etc...). Xamarin will give users a native experience, unlike solutions like PhoneGap or Titanium.

现在Objective-C比c#有一些优势,但在大多数情况下,用c#编写应用程序通常会减少开发时间和更清晰的代码,并减少将同一应用程序移植到其他平台的工作。一个值得注意的例外可能是依赖OpenGL的高性能游戏。

其他回答

如果这是你唯一要开发的iPhone应用程序,而你对开发Mac应用程序毫无兴趣,那么MonoTouch可能是值得的。

如果你想要开发更多的iPhone应用,或者想要做一些Mac原生开发,那么学习Objective-C和相关框架可能是值得的。另外,如果你是那种喜欢学习新东西的程序员,这是一个有趣的新范式。

我换了。Monotouch让我编写应用程序的速度至少提高了3-4倍(与我以前在Obj C中每月1个应用程序相比,每月4个)

打字少了很多。

只是我的经验。

使用Mono并不是一种依赖。它为iPhone操作系统增加了很多功能。LINQ, WCF, Silverlight应用程序之间的可共享代码,ASP。NET页面,一个WPF应用程序,一个Windows Form应用程序,还有针对Android的mono它也适用于Windows Mobile。

So, you can spend a bunch of time writing Objective-C (You'll see from many studies where the exact same sample code in C# is significantly less to write than OC) and then DUPLICATE it all for other platforms. For me, I chose MonoTouch because the Cloud App I'm writing will have many interfaces, the iPhone being only one of them. Having WCF data streaming from the cloud to MonoTouch app is insanely simple. I have core libraries that are shared among the various platforms and then only need to write a simple presentation layer for the iPhone/WinMobile/Android/SilverLight/WPF/ASP.NET deployments. Recreating it all in Objective-C would be an enormous waste of time both for initial dev and maintenance as the product continues to move forward since all functionality would have to be replicated rather than reused.

那些侮辱MonoTouch或暗示它的用户需要拐杖的人,是缺乏拥有。net框架的大蓝图,可能不理解逻辑与表示的正确分离,这种分离可以在跨平台和设备上重用。

Objective-C is interesting and very different from many common languages. I like a challenge and learning different approaches... but not when doing so impedes my progress or creates unnecessary re-coding. There are some really great things about the iPhone SDK framework, but all that greatness is fully supported with MonoTouch and cuts out all the manual memory management, reduces the amount of code required to perform the same tasks, allows me to reuse my assemblies, and keeps my options open to be able to move to other devices and platforms.

三个字:Linq to SQL

是的,很值。

我会花时间在Objective-C上,主要是因为你可以从这样的网站上得到帮助。Objective-C的优点之一是你可以使用C和c++代码,而且有很多项目都经过了很好的测试。

另一件事是你的代码(语言选择)将被苹果支持。什么是ios5。例如,x删除了对第三方解决方案如MonoTouch?你会怎么告诉你的客户?

如果你还没有完全准备好转向Objective-C,也许使用HTML5等独立于平台的解决方案会更好?