Created
September 11, 2011 18:04
-
-
Save epatel/1209907 to your computer and use it in GitHub Desktop.
UIImage encoderWithCoder: and initWithCoder: (PNG style)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface UIImage (NSCoder) | |
- (void)encodeWithCoder:(NSCoder*)encoder; | |
- (id)initWithCoder:(NSCoder*)decoder; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIImage+NSCoder.h" | |
@implementation UIImage (NSCoder) | |
- (void)encodeWithCoder:(NSCoder*)encoder | |
{ | |
[encoder encodeDataObject:UIImagePNGRepresentation(self)]; | |
} | |
- (id)initWithCoder:(NSCoder*)decoder | |
{ | |
return [self initWithData:[decoder decodeDataObject]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment