Thanks. I can't claim it - I think I got it from Frank Kruger - but it's really useful.
On Mon, May 28, 2012 at 12:58 AM, Greg Munn <[email protected]> wrote: > Awesome response Nic, I've now just found about UIKitScheduler. > > Cheers, > Greg > > > On 28/05/2012, at 3:56 AM, Nic Wise wrote: > >> All of this is IMO, of course :) >> >>> 1. How good is the string/character manipulation performance of MonoTouch in >>> comparison to Objective C? Is it almost as fast? >>> >> >> Should be the same or faster. There may be a very small overhead going >> from a string <-> NSString, but we would be talking nano seconds, I >> suspect. If you are just manipulating strings in your app, not passing >> them to Obj-C code (ie, CocoaTouch) then both should be about the same >> - c#/mono's string handling is, as far as I know, as good as desktop >> .NET (that said you are running on a lower-ghz CPU, so ....) >> >>> 2. How good is the floating point math performance of MonoTouch in >>> comparison to Objective C? >>> >> >> I'd have to let someone from Xamarin answer that, but FP math is built >> into the CPU, I think, so... should be native speeds?? A float is a >> float when you are looking at ARM binary code. >> >> I think MonoTouch can use the SMID stuff on the arm chips, ie the ARM >> equivalent to SSE/MMX .... >> >> Sorry, not something I've had to look into. I suspect it'll be the >> same as Obj-C, unless you are working with data types which are not >> CPU-native. >> >>> 3. My C# program is currently around 500k in filesize. How much would this >>> translate to once it's ported with MonoTouch? >> >> Depends on too many things. Usually, start with 1.5Meg (hello world), >> and go up from there. >> >> you C# app isn't 500k. It's 500k of IL + the .NET framework, which is >> usually about 20meg or so. MonoTouch has to bundle some of that >> framework into the exe, as there is no framework on the phone. the >> linker gets rid of a lot of it tho. >> >> In my current "larger" app (earnestapp.com) the assembles are around >> 2.5meg (IL code - .DLL/.EXE) and the resulting binary is about 8meg. >> On top of that, I have around another 5meg of images and other >> resources, and it zips down to 7meg (ALL apps are sent out and >> submitted to apple as zips - aka IPA's. Look in iTunes, find one, copy >> it, rename to .zip, unzip and have a look) >> >> If it's all non-visual C#, and doesn't pull in a lot of other stuff, >> then I suspect it'll be quite small. But it's very much "how long is a >> piece of string". >> >>> >>> 4. How much of the code would I need to change when using MonoTouch? Apart >>> from GUI stuff, I'm hoping very little. For example, if I have lines like >>> these (unrelated): >>> >>> - CultureInfo.CurrentCulture.TextInfo.ListSeparator >>> >>> - text.Split(new string[] { "TEST" }, >>> StringSplitOptions.RemoveEmptyEntries); >>> >>> - Convert.ToDouble(myVar, CultureInfo.InvariantCulture) >>> >>> - (measure)Enum.Parse(typeof(measure), myVar) >>> >>> - Array.Resize(ref ops, i) >>> >>> ....could I use those pieces of code directly, or would they need >>> adjusting for MonoTouch? >>> >> >> I'd say they would work, off the top of my head. Most of the issue is >> around Reflection.Emit, so when you emit some IL and then execute it. >> >>> 5. I use the TimeSpan and DateTime classes. Are these fully supported with >>> MonoTouch? >> >> yes. >> >>> 6. How thorough is the Globalization library and CultureInfo class support? >>> Will MonoTouch recognize the decimal point character etc.? >>> >> >> Yes. And the CocoaTouch ones have very good support for I18N, too, >> baked into the OS. Makes windows look awful (which it is) >> >> I use this, for example: >> >> return CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; >> >> So that German's get 10,00 and UK gets 10.00 >> >>> 7. How is the File class used? Are disc access MonoTouch functions >>> equivalent to their pure C# counterparts? How about a piece of code such as >>> `Application.StartupPath`? >> >> Yes. File works just fine. There are a few restrictions - you can't >> write into your .app folder, but you have a "Documents" folder, a >> "Library" folder and other stuff. The .NET-specific IsolatedStorage >> stuff works find (accross MonoTouch, MonoForAndroid, WP7, Silverlight, >> Win8, Win7 etc) >> >> This might help: >> >> http://docs.xamarin.com/ios/tutorials/Working_with_the_File_System >> >> One thing to note: you really should (must?) use Path.Combine. iOS is >> Unix. Unix is /. Windows is \ >> >> This will not work on iOS (at all, ever): >> >> .\Documents\myfile.txt >> >> it has to be >> >> ./Documents/myfile.txt >> >> Path.Combine will get this right based on the OS. >> >>> 8. In C#, the RichTextBox supports Rtf as input. Will MonoTouch allow me to >>> use an equivalent GUI widget which allows Rtf input? >>> >> >> Not as far as I know. The default iOS textbox doesn't do rich text, at >> least as far as I've seen. You'd be writing your own - even if you use >> Obj-C. >> >> iOS has native PDF, which might work if you can convert the RTF to PDF >> if it's for viewing. >> >>> 9. How about HttpWebRequest, WebRequest, and GlobalProxySelection for >>> reading a file from the web? >> >> Yup. All work - I use them. WebClient works too. >> >> Check with Xamarin to see if the Proxy stuff picks up the device proxy >> now. It never used to, but it might do now. I tend to set it in my >> code as needed, tho. >> >> If you use the CocoaTouch native stuff, it all picks up the system >> proxy, but thats also based on a whole different delegate-driven >> model. >> >>> >>> 10. Is threading supported well, including the background worker system? >> >> Yes. you can also use System.Threading.Tasks (which is sweet), as well >> as Thread.QueueWorkItem etc. >> >> Task.Factory.StartNew(() => { >> return "do some stuff on the thread"; >> }).ContinueWith(taskResult => { >> Console.WriteLine("oh, I'm on the main thread now!"); >> }, new UIKitScheduler()) >> >> This is also handy for the UIKitScheduler, which makes sure the >> continuewith is run on the CORRECT UI thread. >> >> https://gist.github.com/1431457 >> >>> 11. Are dictionaries fully supported? >>> >> >> You mean System.Collection.Dictionary? and >> System.Collections.Generics.Dictionary<T,U>? Yes. All of >> System.Collections[.Generic] is there. >> >>> 12. And finally, with Monotouch, can I mix C# and objective C code if I >>> wanted to? Or does it all have to be C#? >> >> You can write Obj-C and make it into a library (.a - object file), and >> then link that in. There is a fairly large bunch of bindings on github >> for various things which work like this, including Google Analytics, >> TestFlightapp.com and a load of others. It's not trivial to write at >> first, but it's not overly hard either. >> >> https://github.com/mono/monotouch-bindings >> >> All of these take the published Obj-C output and integrate it into MonoTouch. >> >> Some things to remember: >> >> 1. Your desktop machine is (most likely) a quad or 8 core 3.2Ghz >> machine with 8-16GB RAM and unlimited swap. An iPhone 4S has 512meg >> (1GB?) + 800mhz CPU. And _no_ swap. You can't load a huge document >> into memory and expect it to work! >> >> 2. Get as much off the UI thread (the main thread) as possible. this >> will make your app _feel_ faster, as the animations and the like will >> be smooth, even if the app is taking a while to do something. Async >> programming is pretty much a requirement (you can "not do it" but the >> results are usually kinda awful) >> >> 3. Consider rethinking what your app does. You are (I suspect) moving >> from a 24" screen to a 3.5" one (or 9" for the iPad). Mouse+Keyboard >> -> finger. The same UI paradigms don't port over very well. Consider >> reading Tapworthy by Josh Clark: >> http://shop.oreilly.com/product/0636920001133.do or some other iOS >> design books. I'm not talking about pixel pushing (tho having a full >> time designer is a huge help), but more thinking in the context of the >> user, what they are doing, WHEN and WHERE they are doing it, etc. >> >> 4. Plan the app out on paper before you code a line. Scan the paper in >> and get a feeling for it using the Photos app on the phone. There are >> iOS templates around that you can build realistic wireframe (google >> "Teehan and Lax") or just use pen/graph paper or Balsamiq. You can >> work out a lot of issues cheaply doing this. Briefs is quite good for >> this: >> >> http://giveabrief.com/ >> >> (not sure it works anymore tho - Apple pulled it from the appstore, so >> it's a bit manual now) >> >> 5. CocoaTouch is a big API, as is .NET or Windows. Expect it to take a >> little while to learn the ins and outs of how it works. It has a >> different design philosophy to windows or .NET (highly OO, lots of use >> of patterns eg delegate), but it also provides you with a huge amount >> of functions - esp in the UI. >> >> Hope that helps. >> >> Nic >> -- >> Nic Wise >> t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise >> b. http://www.fastchicken.co.nz/ >> >> Earnest: Self-employed? Track your business expenses and income. >> http://earnestapp.com >> Nearest Bus: find when the next bus is coming to your stop. >> http://goo.gl/Vcz1p >> mobileAgent (for FreeAgent): get your accounts in your pocket. >> http://goo.gl/IuBU >> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa >> London Bike App: Find the nearest Boris Bike, and get riding! >> http://goo.gl/Icp2 >> _______________________________________________ >> MonoTouch mailing list >> [email protected] >> http://lists.ximian.com/mailman/listinfo/monotouch > -- Nic Wise t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise b. http://www.fastchicken.co.nz/ Earnest: Self-employed? Track your business expenses and income. http://earnestapp.com Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2 _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
