Core data accessors for structs
Core data accessors for structs
- Subject: Core data accessors for structs
- From: MH <email@hidden>
- Date: Mon, 25 Jun 2007 14:38:05 +0100
Hi Folks,
I've been looking at:
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html
Although this seems to work fine. Are there any other issues that I'm
overlooking?
Also, I'm concerned that I loose KVC compliance using these kinds of
accessors.
Is there a way to restore KVC in this situtation?
- (myStruct)foo
{
[self willAccessValueForKey:@"foo"];
myStruct bar = foo;
[self didAccessValueForKey:@"foo"];
NSData *fooAsData = [self valueForKey:@"foo"];
if (structAsData != nil) {
[structAsData getBytes:&bar length:sizeof(myStruct)];
}
return bar;
}
- (void)setFoo:(myStruct)newFoo
{
[self willChangeValueForKey:@"foo"];
foo = newFoo;
[self didChangeValueForKey:@"foo"];
NSData *fooAsData = [NSData dataWithBytes:&newFoo
length:sizeof(myStruct)];
[self setValue:fooAsData forKey:@"foo"];
}
Many thanks.
_______________________________________________
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