Re: awakeFromInsert is not called
Re: awakeFromInsert is not called
- Subject: Re: awakeFromInsert is not called
- From: Chris Hanson <email@hidden>
- Date: Mon, 14 Nov 2005 11:01:20 -0800
On Nov 14, 2005, at 4:01 AM, Kubernan from 10191 Technologies wrote:
Because i need to set an entity with default values, i followed
the apple doc : NSPersistentDocument core data tutorial.
To set non-computed default values for the attributes of an instance
of an entity, you should just be able to specify them in the Xcode
data modeling tools. You don't need to override -awakeFromInsert.
So, i created a custom managed object class (called
groupUpdateOption) adding awakeFromInsert like this :
Cocoa coding conventions are to use initial capital letters for class
names (e.g. GroupUpdateOption).
+ (void)initialize
{
self = [groupUpdateOption class];
}
It's not clear to me why you believe this to be necessary; it doesn't
do much of anything.
- (void)awakeFromInsert
{
NSLog(@"awakeFromInsert is calling");
[super awakeFromInsert];
[self setValue:[NSNumber numberWithInt:1]
forKey:@"numberOfDays"];
[self setValue:@"Once a day"
forKey:@"updateOption"];
}
This is correct, and will be invoked after an instance of this entity/
class has been inserted into a managed object context.
I have a NSArray controller associated to this class (i.e. as an
Entity in the controller inspector).
In my model, i modified the class name from NSManagedObject to
groupUpdateOption.
The above sounds correct. Do you also have a managed object context
specified for your array controller? You'll probably just want to
start out using the managed object context of File's Owner if you're
creating a single-nib document.
Starting my application, it appears awakeFromInsert is never
called. What should i do for that ?
Do you create and insert an instance of your entity anywhere? Doing
so doesn't happen automatically, you need to write code to do so.
-- Chris
_______________________________________________
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