Prior to iOS 5.1 if you wanted to use NSCoding protocols with UIImage you had to do something like this.
@interface UIImage (NSCoding)
-(id)initWithCoder:(N
One way is to dynamically patch the UIImage class to add the needed methods when running on iOS 4 (or better, when the methods are missing). Here’s a sample project on GitHub that does something similar, it adds controller containment support for iOS 4 (the key is the class_addMethod function). But this is too much magic for production code, so if there’s a simpler answer, go with it.