iOS Mobile Development. Titanium vs Native, a Dev's Perspective
I have been developing native iOS applications since 2007, back when the first App Store was introduced, and have only been involved in writing native code (Objective C) mixed with some C/C++ (for usage with libraries and frameworks).
It wasn't until a few months ago that I started working with Appcelerator's Titanium. For those who don’t know what Titanium is, it’s basically a developer environment that allows you to write apps for iOS, Android and web, all using one code base and without ever touching native code.
Diving into the Depths of Titanium Development
The first project I did with Titanium was an app that communicated with Apple's movie trailers page. It retrieved a JSON file from Apple's server, parsed it and converted it to useful data and then showed it in a table view.
Movie Trailers app created in Titanium
Cocoa Touch doesn't offer this kind of control because the behaviour of the table view is done through delegates. You can customize the table view, and the table rows, but it's a bit limiting and requires you to do subclassing.
But that's not all, you can add event listeners to all elements you create, which makes virtually every visual component respond to a specific event. You can't do that in Cocoa Touch, not for all elements at least. For example, you could add an event listener to a window in Titanium, but in Cocoa you can't. You would need to add a subview and make that respond to events.
Event triggered when selecting a row
Receiving data from a URL in Titanium
In Cocoa Touch, it used to be a lot harder because you had to implement delegates and for some developers that was confusing and a lot of work. There were quite some delegate methods you needed to implement because many things could happen when you did a network request.
The more recent versions of the iOS SDK offer a simplified way of doing this: just one call, thanks to the blocks feature of the language.
Receiving data from a URL in Cocoa Touch
The Result and Final Thoughts
In the end I finished the Movie Trailers application using Cocoa Touch, simply because I'm more familiar with it and because I wanted to add more features which I didn't know how to do in Titanium. Some of those things include creating a grid view where each cell has rounded corners and has a drop shadow (generated by Core Graphics, an API for iOS) and some cool transition effects.
You can see the final version of the app in the screenshot below.
Final Movie Trailers - done in Cocoa Touch
Like I said in the beginning of this article, Titanium is great for doing cross-platform development, but for some other application which require delving deeper into what the OS has to offer you may be better doing it natively. But for general purpose apps Titanium is a great solution and it’s easy to learn.
About the Author
Jesus De Meyer has been developing apps for Mac for over 15 years and iOS for over 5 years. He finished his studies at the PIH university in Kortrijk, Belgium and has been writing apps for the Mac and iOS App Store's ever since. He's currently working at iTexico as an iOS developer and in his spare time he is making apps for himself.