Re: Core Data and/or bindings: setting dynamic default values for properties?
Re: Core Data and/or bindings: setting dynamic default values for properties?
- Subject: Re: Core Data and/or bindings: setting dynamic default values for properties?
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 10 Jun 2005 02:34:00 -0700
On Jun 10, 2005, at 2:14 AM, Daniel DeCovnick wrote:
is there an easy way to set a dynamic default value for a property.
Directly, no:
setDefaultValue:
- (void)setDefaultValue:(id)value
Sets the default value of the receiver to value. This method raises
an exception if the receiver’s model has been used by an object graph
manager.
Note that default values are retained by a managed object model, not
copied (this means that attribute values do not have to implement
NSCopying). This means, however, that you should not modify any
objects after they have been set as default values.
You *may* be able to subclass NSAttributeDescription and override the
-defaultValue method to return an appropriate value. You would have
to modify your model on load to use an instance of your class in
place of the relevant attribute or attributes. You could store
"instructions" in the entity's userInfo dictionary...
Otherwise the appropriate (and rather more convenient) place is -
awakeFromInsert.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden