UIImage and NSCoding iOS 5.1

后端 未结 3 405
醉话见心
醉话见心 2020-12-20 22:01

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         


        
3条回答
  •  渐次进展
    2020-12-20 22:24

    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.

提交回复
热议问题