UIImage-NSCoding.h
//
// UIImage-NSCoding.h
UIImage-NSCoding.m
//
// UIImage-NSCoding.m
This is also checked into Google Code if you prefer to grab it from there.
//
// UIImage-NSCoding.h
#import <Foundation/Foundation.h>
@interface UIImageNSCoding <NSCoding>
- (id)initWithCoder:(NSCoder *)decoder;
- (void)encodeWithCoder:(NSCoder *)encoder;
@end
//
// UIImage-NSCoding.m
#import "UIImage-NSCoding.h"
#define kEncodingKey @"UIImage"
@implementation UIImage(NSCoding)
- (id)initWithCoder:(NSCoder *)decoder
{
if ((self = [super init]))
{
NSData *data = [decoder decodeObjectForKey:kEncodingKey];
self = [self initWithData:data];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
NSData *data = UIImagePNGRepresentation(self);
[encoder encodeObject:data forKey:kEncodingKey];
}
@end
No comments:
Post a Comment