Managed Object with Transformable Attribute (C Struct)
Managed Object with Transformable Attribute (C Struct)
- Subject: Managed Object with Transformable Attribute (C Struct)
- From: Richard Somers <email@hidden>
- Date: Tue, 15 Dec 2009 17:24:48 -0700
I have a managed object with a transformable attribute. The attribute
is a C struct and uses a custom value transformer. The transformer
uses the depreciated NSArchiver but it is drop dead simple and it works.
I am trying to implement keyed archiving and can't figure out what to
do or which way to go. I can't seem to see the forest for the trees
and keep going around in circles in the documentation and on the web.
The C struct "Foo" is defined like this.
typedef struct { double a; double b; double c; double d; } Bar;
typedef struct { Bar e; Bar f; } Foo;
The current custom value transformer.
@interface MyArchiveToDataTransformer : NSValueTransformer
@end
@implementation MyArchiveToDataTransformer
+ (Class)transformedValueClass
{
return [NSData class];
}
+ (BOOL)allowsReverseTransformation
{
return YES;
}
- (id)transformedValue:(id)value
{
return [NSArchiver archivedDataWithRootObject:value];
}
- (id)reverseTransformedValue:(id)data
{
return [NSUnarchiver unarchiveObjectWithData:data];
}
@end
Any suggestions or insight for the lost and confused?
--Richard
_______________________________________________
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