• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using NSValueTransformer to convert NSImage to NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSValueTransformer to convert NSImage to NSData


  • Subject: Using NSValueTransformer to convert NSImage to NSData
  • From: Peter Zegelin <email@hidden>
  • Date: Tue, 24 Mar 2009 23:39:33 +1100

I am trying to bind an NSImageView to my shared user defaults so that when a user drops an image onto the control it is automatically scaled and saved to the users preferences file. I have made a subclass of NSValueTransformer to convert NSImage <> NSData for saving to the defaults but am having no luck getting any further. When an image is dropped my reverseTransformedValue is called but I have no idea what to do next. I can't even figure out what 'value' is:


- (id)reverseTransformedValue:(id)value

[value description] gives just a string <................> with nothing obvious in it.


So how do I transform whatever value is into an NSData object for archiving?


My class is as follows:

@implementation ImageScalingAndArchivingTransformer // subclass of NSValueTransformer

+ (Class)transformedValueClass { return [NSImage class]; }
+ (BOOL)allowsReverseTransformation { return YES; }


- (id)reverseTransformedValue:(id)value {

// what to do here to scale an image to icon size and convert it to NSData?
}



- (id)transformedValue:(id)value {

// I am just returning the value here for now as it is currently 0x00 anyway.
return value;
}



thanks for any insights!

Peter
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Using NSValueTransformer to convert NSImage to NSData
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: NSObliquenessAttributeName, labelFontOfSize, & Italic
  • Next by Date: Re: Using NSValueTransformer to convert NSImage to NSData
  • Previous by thread: Re: Trouble with NSAnimationContext
  • Next by thread: Re: Using NSValueTransformer to convert NSImage to NSData
  • Index(es):
    • Date
    • Thread