Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XMPPRosterCoreDataStorage] Fix photo attribute to support both UIIma…
…ge and NSImage.
- Loading branch information
Eric Chamberlain
committed
Apr 7, 2011
1 parent
0cd633b
commit ea83a3e
Showing
4 changed files
with
67 additions
and
126 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 | |||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.