Sunday Thoughts: working in iOS
Having spent the last few weeks immersed in iOS – high time! – I offer a few observations.
- XCode 4 is an impressive IDE. Running on my new i7 MacBook Air, it’s delightfully fast. Integrating the Clang/LLVM compiler with the editor is a big win, even though it spends a lot of time telling me things I already know. Yes, this function doesn’t return anything. I haven’t finished writing it yet. As you can tell. Just wait half a minute while I finish typing. There.
- It’s fun to be working with fresh code again, even for small projects.
- Cocoa Touch, also known as UIKit, is an interesting framework. To avoid lots of subclassing, it embraces delegates (which other frameworks call protocols or policy objects) all over the place. This is a nice use of what Objective C does well.
- I miss overloading in C++. I really miss protected inheritance.
- Getting XCode 4 to talk to Subversion was a bear. It’s working now. I think. I’ve scant idea exactly what used to be wrong, or what’s right now; I think it might relate to an SSL certificate authority and Beanstalk.
- The Objective C idiom for private methods is to declare them in the implementation (.m) file, not the header (.h). I have a shelf full of introductory texts for Objective C and Cocoa. None of them highlight this. Offhand, this is one of the most important and obscure language issues confronting the immigrant from C++, or indeed from any good object-oriented language.
- Cocoa memory management is tricky, especially after an injudicious bit of documentation convinced iPhone coders that autorelease was a Bad Thing. You can’t avoid autorelease, so it can’t be a bad thing. None of my iPhone books (and I have a bunch) do a very good job with memory management idioms.
- Apparently, iOS 5 will make all this memory management headache vanish into thin air.
- On the whole, the Apple documentation is more accessible to the educated reader than are the numerous volumes from technical presses. This is a change from the way things used to work. Apple is its own Osborne, its own Petzold.
- A number of books about “getting started” with iPhone or iPad or Cocoa programming are badly conceived, being aimed at people who don’t have sufficient background to do the job properly. They try to explain object-oriented programming, memory management, and a complicated framework from ground zero. It’s one thing to explain syntax, but another thing to try to cram syntax and three years of computer science into 600 pages. Trying to learn to program UIKit is not a lot like trying to learn to program Commodore PET BASIC, but the books look remarkably alike.
- Stack Overflow isn’t half bad, half of the time.