在今天的一个本地。net活动上,Mono的使用被“提及”为iPhone开发的替代方案。在c#和。net中非常舒适,这似乎是一个有吸引力的选择,尽管Mono堆栈有一些奇怪的地方。然而,由于MonoTouch的售价为400美元,我有些纠结于这是否是iPhone开发的发展方向。
有人用MonoTouch和Objective-C开发过吗?如果是的话,用MonoTouch开发比学习Objective-C更简单、更快,而且值得花400美元吗?
在今天的一个本地。net活动上,Mono的使用被“提及”为iPhone开发的替代方案。在c#和。net中非常舒适,这似乎是一个有吸引力的选择,尽管Mono堆栈有一些奇怪的地方。然而,由于MonoTouch的售价为400美元,我有些纠结于这是否是iPhone开发的发展方向。
有人用MonoTouch和Objective-C开发过吗?如果是的话,用MonoTouch开发比学习Objective-C更简单、更快,而且值得花400美元吗?
当前回答
我换了。Monotouch让我编写应用程序的速度至少提高了3-4倍(与我以前在Obj C中每月1个应用程序相比,每月4个)
打字少了很多。
只是我的经验。
其他回答
我已经使用MonoTouch几个月了,我从ObjectiveC移植了我的半成品应用,这样我就可以在未来的某个时候支持Android。
以下是我的经验:
不好的地方在于:
Xamarin Studio. Indie developers such as myself are forced into using Xamarin Studio. It is getting better every week, the developers are very active on the forums identifying and fixing bugs, but it's still very slow, frequently hangs, has a lot of bugs and debugging is pretty slow also. Build times. Building my large (linked) app to debug on a device can take a few minutes, this is compared to XCode which deploys almost immediately. Building for the simulator (non-linked) is a bit quicker. MonoTouch issues. I've experienced memory leak issues caused by the event handling, and have had to put in some pretty ugly workarounds to prevent the leaks, such as attaching and detaching events when entering and leaving views. The Xamarin developers are actively looking into issues like this. 3rd party libraries. I've spent quite a time converting/binding ObjectiveC libraries to use in my app, although this is getting better with automated software such as Objective Sharpie. Larger binaries. This doesn't really bother me but thought I'd mention it. IMO a couple of extra Mb is nothing these days.
好的方面:
多平台。我的朋友很高兴地用我的核心代码库为我的应用程序创建了一个Android版本,我们正在并行开发,并将其提交给Dropbox上的远程Git存储库,进展顺利。 . net。在c# . net中工作比在Objective C中工作要好得多。 MonoTouch。iOS中几乎所有的东西都映射到。net中,让事情正常工作是相当直接的。 Xamarin的。你可以看到这些人真的在努力改进一切,使开发更顺畅和更容易。
我强烈推荐Xamarin进行跨平台开发,特别是如果你有钱使用与Visual Studio合作的商业版或企业版。
如果你只是在创造一款在其他平台上永远都不需要的iPhone应用,并且你是一名独立开发者,那么我现在会坚持使用XCode和Objective C。
三个字:Linq to SQL
是的,很值。
在这篇文章中有很多开发者没有尝试过MonoTouch和Objective-C的传闻。似乎大多数Objective-C开发者从未尝试过MonoTouch。
我显然是有偏见的,但你可以看看MonoTouch社区一直在做什么:
http://xamarin.com
在那里,你会发现一些开发人员用Objective-C和c#开发的文章。
补充一下其他人已经说过的话(好吧!):我的感觉是你基本上把你需要担心的bug数量增加了一倍,把MonoTouch中的bug添加到iPhone OS中已经存在的bug中。更新新的操作系统版本将比正常情况下更加痛苦。恶心,到处都是。
我认为MonoTouch唯一引人注目的情况是,那些有大量c#程序员和c#代码的组织必须在iPhone上使用。(就是那种3500美元都不眨眼的商店。)
但对于任何从零开始的人来说,我真的不认为这是值得或明智的。
作为一个同时拥有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的高性能游戏。