If you code precompiled libraries for people to use (frameworks, static libraries etc) you may want to hide your variables from the headers so other coders know as little about how your classes work as possible. It works similar to categorising a class and adding new methods, except you can also use new variables that only the implementation file (.m) knows about.
Since the introduction of iOS4, blocks have become very prevalent in the Cocoa framework as a quick and non messy way of implementing a ‘callback’. Blocks can be passed around just like any other variable. They are most used in UIView animations.
Harnessing the power and simplicity of blocks is something that I have been doing a lot more since iOS4, turning old fashioned protocol delegates into blocks where it makes sense.
So you’re coding away, everything is coloured nicely so you can distinguish between reserved words, datatypes and variables, but then the unthinkable happens; all your code turns black. Not to worry, you can live without the colours, but when you see the “symbol not found” message and Xcode is no longer autocompleting variables and functions for you, you start the panic. Your development time rolls to a halt and you can no longer quickly jump around from method to method. You realise Xcode has broken it’s intellisense index.
Objective C categories are great for extending classes, however if you want to override methods then you’re going to have some problems as you can no longer call the method on your original class owns, usually breaking a lot of functionality the higher up the class food chain you travel (try this on NSObject‘s init, return nil). If you called the same method on self you would end up with an infinite loop, and calling super will skip the original class completely.
I have recently had a project where I had to do some image processing on an image based on where a user touches an image (in a UIImageView). Getting the touch coordinates was easy enough,