Skip to content

Commit

Permalink
[XMPPRosterCoreDataStorage] Fix photo attribute to support both UIIma…
Browse files Browse the repository at this point in the history
…ge and NSImage.
  • Loading branch information
Eric Chamberlain committed Apr 7, 2011
1 parent 0cd633b commit ea83a3e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 126 deletions.
19 changes: 19 additions & 0 deletions Utilities/RFImageToDataTransformer.h
@@ -0,0 +1,19 @@

/*
File: RFImageToDataTransformer.h
Abstract: A value transformer, which transforms a UIImage or NSImage object into an NSData object.
Based on Apple's UIImageToDataTransformer
Copyright (C) 2010 Apple Inc. All Rights Reserved.
Copyright (C) 2011 RF.com All Rights Reserved.
*/

#import <Foundation/Foundation.h>


@interface RFImageToDataTransformer : NSValueTransformer {

}

@end
48 changes: 48 additions & 0 deletions Utilities/RFImageToDataTransformer.m
@@ -0,0 +1,48 @@

/*
File: RFImageToDataTransformer.m
Abstract: A value transformer, which transforms a UIImage or NSImage object into an NSData object.
Based on Apple's UIImageToDataTransformer
Copyright (C) 2010 Apple Inc. All Rights Reserved.
Copyright (C) 2011 RF.com All Rights Reserved.
*/

#import "RFImageToDataTransformer.h"

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else

#endif


@implementation RFImageToDataTransformer

+ (BOOL)allowsReverseTransformation {
return YES;
}

+ (Class)transformedValueClass {
return [NSData class];
}

- (id)transformedValue:(id)value {
#if TARGET_OS_IPHONE
return UIImagePNGRepresentation(value);
#else
return [(NSImage *)value TIFFRepresentation];
#endif
}

- (id)reverseTransformedValue:(id)value {
#if TARGET_OS_IPHONE
return [[[UIImage alloc] initWithData:value] autorelease];
#else
return [[[NSImage alloc] initWithData:value] autorelease];
#endif
}

@end

54 changes: 0 additions & 54 deletions Utilities/UIImageToDataTransformer.h

This file was deleted.

72 changes: 0 additions & 72 deletions Utilities/UIImageToDataTransformer.m

This file was deleted.

0 comments on commit ea83a3e

Please sign in to comment.