Re: awakeFromInsert is not called
Re: awakeFromInsert is not called
- Subject: Re: awakeFromInsert is not called
- From: Kubernan from 10191 Technologies <email@hidden>
- Date: Mon, 14 Nov 2005 20:36:24 +0100
First, thanks for your help,
Le 14 nov. 05 à 20:01, Chris Hanson a écrit :
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.
Right. I'm not enough clear : what i want to do is to create several
instances of an entity.
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).
Yep. It's a typo...
+ (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.
Ahaha. I'm stupid ! I don't know why but i thought awakeFromInsert
was automatically called once the manage object context
was loaded... Sorry, i'm just learning core date ;-)
So, what i want is a list of static values such as "Once a week",
"Once a day", "Once a month". Each is an instance of the entity
"groupUpdateOption" If i well understand
i don't need to use awakeFromInsert. I just have to create 3 entity
instances.
The entity "groupUpdateOption" has relationship with other entity, so
my question is where is the best place into my code
for creating these three default instances ?
-- Chris
K. _______________________________________________
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