Another benefit of moving to Mac OS X has been the chance to learn how to write applications for my iPhone. Since getting my iPhone last July (I think?) I’ve been pretty much welded to the thing, it’s very convenient to have the Internets in your pocket!
While faffing around looking for Mac software I noticed that Apple give away an IDE capable of writing both native Mac apps and iPhone apps. It’s not exactly free to write iPhone apps, you have to pay 60 quid for the right to load them onto the actual phone and/or submit them to iTunes – but this didn’t really hinder my surge of enthusiasm. All in all, this is quite a good deal – it’s no wonder so many people have started writing apps for the iPhone.
I’ve now got a list of potential apps I could be working on, but decided to go with the most simple one first. If you head over to The Onion, you’ll find this video, which formed the basis of the idea. I also quite liked the idea of my first submission to the App Store being a mild piss-take of Apple.
I’ve translated it into my first app, Touch Wheel.
I’m pretty sure you can tell how it works by just by looking at it (the interface is so intuitive after all!) – you scroll through letters by sliding your finger around the wheel. Pressing the centre circle adds the letter to your message. The forward and back arrows add spaces or delete characters respectively. The up arrow switches between upper and lower case. When you’re done, pressing the Mail button puts your message into an email and transfers you over to the email app on the phone so you can send your masterpiece to the world!
Obviously this is all quite simple but it let me get my head round a lot of things in Objective-C and Cocoa Touch – I had no experience with either prior to this. As a Java programmer, a lot of the OO ideas are quite familiar but there are a few real pains – some are because I’m so accustomed to Java, others just seem deliberately broken. Examples of both:
- Pointers – these make no sense to me at the moment. In Java everything is a pointer, when an object is not referenced by any pointers then it’s gone and the memory it occupies is freed up. I’m starting to get to grips with the alloc/retain/(auto)release stuff but I’m still not completely clear on when to use/avoid pointers. Sometimes the compiler complains if I get it wrong, but I guess there must be times when you have the option? Am I safe to just use pointers all the time, making it a pseudo-Java language (with the added complexity of deliberately managing your own memory)?
- Strings. What a hassle! Making/concatenating strings is so painful. Why can’t they have ‘+’ work with Strings? Why do you need to start a constant string with @” instead of just “?
When I get some time I’ll make a start on my next app, which should be more complex, but I also have some ideas for the upgrade to Touch Wheel. This upgrade could happen in one of two ways: either Touch Wheel appears on iTunes and I can start work on the update, or it gets rejected (which, let’s face it, is more likely) and I have to add stuff to make it more useful. There is also the possibility it will get rejected for imitating a famous Apple device, in which case a more fundamental re-think will be required.