Re: Managed Object with Transformable Attribute (C Struct)
Re: Managed Object with Transformable Attribute (C Struct)
- Subject: Re: Managed Object with Transformable Attribute (C Struct)
- From: Richard Somers <email@hidden>
- Date: Tue, 15 Dec 2009 21:11:42 -0700
On Dec 15, 2009, at 6:36 PM, Jerry Krinock wrote:
Concentrate on this one:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Archiving/Tasks/codingctypes.html
Ok. I changed -transformedValue: of the custom value transformer to
look like this.
- (id)transformedValue:(id)value
{
Foo foo;
[value getValue:&foo];
NSMutableData *data = [NSMutableData dataWithCapacity:64];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[archiver encodeDouble:foo.e.a forKey:@"e.a"];
[archiver encodeDouble:foo.e.b forKey:@"e.b"];
[archiver encodeDouble:foo.e.c forKey:@"e.c"];
[archiver encodeDouble:foo.e.d forKey:@"e.d"];
[archiver encodeDouble:foo.f.a forKey:@"f.a"];
[archiver encodeDouble:foo.f.b forKey:@"f.b"];
[archiver encodeDouble:foo.f.c forKey:@"f.c"];
[archiver encodeDouble:foo.f.d forKey:@"f.d"];
[archiver finishEncoding];
return [NSKeyedArchiver archivedDataWithRootObject:value];
}
When I save the document I get an error: *** -[NSKeyedArchiver
encodeValueOfObjCType:at:]: this archiver cannot encode structs.
Any ideas what's wrong?
--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