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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to