Core Data Question

I have a custom struct that I would like to make key-value coding compliant so 
it will work with Core Data as a non-standard persistent attribute. Is it 
possible to make a custom struct key-value coding compliant?

I would rather not store it in the managed object as an object but would like 
to leave it as a struct and have it work just like NSPoint, NSSize, NSRect, or 
NSRange.

Core Data Programming Guide
Non-Standard Persistent Attributes
Scalar Value Constraints

"A requirement of the accessor methods you write is that they must be key-value 
coding (and key-value observing) compliant. Key-value coding only supports a 
limited number of structures—NSPoint, NSSize, NSRect, and NSRange."

"If you want to use a scalar type or structure that is not one of those 
supported directly by Core Data and not one of the structures supported by 
key-value coding, you must store it in your managed object as an 
object-typically an NSValue instance, although you can also define your own 
custom class. You will then treat it as an object value as described later in 
this article. It is up to users of the object to extract the required structure 
from the NSValue (or custom) object when retrieving the value, and to transform 
a structure into an NSValue (or custom) object when setting the value."

--Richard


_______________________________________________

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

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

Reply via email to