Book review: Learning Monotouch by Michael Bluestein | Peter van Ooijen
Monotouch is a powerful tool to create native iOS (iPhone/iPad/iPod) apps written in C# backed by (a native version of) the .net framework. I have been using it for some time now to my great satisfaction. Learning Monotouch was a somewhat bumpy road. The native language for iOS is objective C and the majority of the resources on iOS development use that language. Objective C is on itself not a bad language at all. But the syntax is somewhat awkward and the philosophy differs enough from C# to make the learning curve for us .net-ers rather steep.
There are a lot of resources on the web on Monotouch, a lot with practical hands on examples. They do learn you how to build working (and appstore accepted apps) but not many of them spend any attention on the background or architecture of iOS. Making it hard to understand all Objective C resources, even having learned the syntax.
The book is a hands-on guide, everything is explained in clear example apps. In the first chapters the same app is demonstrated in XCODE-Objective C (Apple’s tools)and in Monotouch. Doing so it both explains the architecture of an iOS app and explains the way Monotouch handles that. In case you are already working with Monotouch: do get this book and do not skip these first chapters. Besides a better understanding of your apps Michael also spends a lot of attention to the details, there is a lot of quality to be won in fine tuning the result of the default app template.
The book assumes you are familiar with C#, lambda expressions and extension functions are used without introduction. Those things show how good an idea Monotouch is, these are powerful language features not offered by objective C. The book also assumes you are familiar with the .Net framework. Parts are used throughout the chapters. “Our” framework really has more to offer than the native Apple tools, especially when it comes to webservice clients and xml.
The components which make up iOS, visual and non visual, are wrapped up by Monotouch in C# classes. In a number of chapters all pass the revue, ranging from views to the music player. Tables and navigation get a chapter of their own, they are the backbone of almost any iOS app. Thank goodness Michael does start a navigation app with the default windowed app template. Xcode (and thus Monotouch) has a template for a navigation based app, my experience with that is not that good. The way Michael treats navigation in an app works completely outshines all I have ever found so far on the subject. Working through it results in an app that is easy to understand, well integrated and is guarded against common problems. Like popping to a view which has unintended been garbage collected in the mean time. Leading to a blank screen, many an app (including mine..) can suffer from this behavior. Having worked through this chapter I now know how to (really) solve this.
Monotouch and Michael’s coverage don’ stop with of-the shelf components. You can also do hard core bare graphics and animations yourself, the chapter “Graphics and Animations” provide a good start for that. Locations (using GPS) and a chapter on Google Maps using the MapKit follow. Again all very clear and complete containing the essential secrets like how to keep recording location data when your apps switches to the background. Again, this is the book I should have had when I started
A whole chapter is spent on connecting to webservices. SOAP style as well as REST style. Here the .net framework shines again. Networking has a chapter of its own. Which treats the iOS GameKit, which turns out to be a complete peer to peer networking API, and Bonjour, Apple’s networking infrastructure API. In a demo app a client-server scenario, using two iOS devices (!). is demonstrated.
Storage has a chapter of its own. Which describe how to work with app settings (like app.config in .net) and SQLite. SQLlite is not a part of iOS itself, it’s a third party open source database. Using that, will give your app ADO.NET style database access. The nice thing is that several apps can share one and the same database file, a good way to reach out of your app’s sandbox.
A final chapter is spent on the iPad. Having a larger screen it offers specific components to fully utilize that. Michael covers these components and explains how to make your app device aware, with specific screens for iPhone and for iPad.
The book is not about cross-platform development. Monotouch is not a tool for a straightforward port of a Windows phone or MonoDroid (C# for Android) app. Such a tool does not exist, simply because these platforms are different. They are different in the way an user works with apps, they are different in how the user expects the apps to behave. Windows Phone has the Metro interface, which works different as navigating through tables as an iPhone user is used to. You cannot port that, you have to rethink your UI. What can be ported is the non-visual part of the app, where the business logic should be. These parts can be ported, Michael does spend some writing on that, though not that much. Needless to say a good architecture pays of and is beyond the scope of this book.
Some words on the style of the book. It is a hands-on book where your teacher is talking to you, using words like “Let’s create an app” and recipe style fragments. This is a way of writing I do appreciate being “guilty” of doing it myself too. But feedback I received, both from readers and editors, indicates that not everybody does favor it.
To conclude: I can only be lyrical about this book. Once more: I wish I had read it last year. In case you do anything with iOS and .net, just get it. In case you don’t do anything with iOS yet, get it too and expend your C#/.net skills. I hope my walkthrough of the book, and thus of the platform has hinted at the richness of iOS. Let Michael enlighten you to bring it more great apps.