[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Anyone able to help with gdl2?
From: |
Graham Lee |
Subject: |
Anyone able to help with gdl2? |
Date: |
Fri, 21 Jun 2013 16:31:36 +0100 |
Hi,
Having submitted a couple of patches to get GDL2 and EOModelEditor working on
my Mac (see bugs 39289, 39290, 39299), I'm finding that a simple (one-key)
custom record isn't working correctly. Perhaps the problem is between my
keyboard and my chair. I _think_ I'm setting the GDL2 editing stack up
correctly, but would appreciate pointers.
Here's what I'm trying:
- (void)executeCommand: (AddPersonCommand *)command
{
NSAutoreleasePool *localPool = [NSAutoreleasePool new];
NSParameterAssert([command isKindOfClass: [AddPersonCommand class]]);
EOModel *model = [EOModel modelWithContentsOfFile: [[NSBundle mainBundle]
pathForResource: @"SignUp" ofType: @"eomodeld"]];
EODatabase *database = [EODatabase databaseWithModel: model];
EODatabaseContext *dbContext = [EODatabaseContext
databaseContextWithDatabase: database];
EOObjectStoreCoordinator *coordinator = [EOObjectStoreCoordinator new];
[coordinator addCooperatingObjectStore: dbContext];
EOEditingContext *context = [[EOEditingContext alloc]
initWithParentObjectStore: coordinator];
[context setDelegate: self];
Person *newPerson = nil;
EOEntity *personEntity = [model entityNamed: @"Person"];
newPerson = [[personEntity classDescriptionForInstances]
createInstanceWithEditingContext: context
globalID: nil
zone: NULL];
[newPerson setValue: command.name forKey: @"personName"];
[context saveChanges];
[newPerson release];
[context release];
[localPool release];
}
What I know:
- the model is being loaded correctly
- the database is getting the correct adaptor and connection dictionary from
the model
- the model's index.eomodeld identifies the Person entity:
{
EOModelVersion = 2;
adaptorName = PostgreSQL;
connectionDictionary = {
/* redacted */
};
entities = (
{
className = Person;
name = Person;
}
);
storedProcedures = (
);
}
- "Person" is the class generated in EOModelEditor, and is defined in
Person.plist in the model:
{
attributes = (
{
allowsNull = Y;
columnName = name;
externalType = text;
name = personName;
valueClassName = NSString;
}
);
className = Person;
externalName = Person;
name = Person;
relationships = (
);
}
- the newPerson object is an instance of the Person class
- the personEntity object is correct, in that the attributes listed there
match those set in EOModelEditor
- the -setValue:forKey: line raises "this class is not key value
coding-compliant for the key personName."
- [newPerson attributeKeys] is empty
I know 'personName' is an odd choice - I was using 'name' but changed it in
case I was clobbering something. That produced no effect on behaviour, though.
It looks to me like the entity/object is being set up correctly, but that the
EOEntityClassDescription is not looking up the attributes in a way I'd expect.
Does anyone have any suggestions?
Thanks for your help,
Graham.
- Anyone able to help with gdl2?,
Graham Lee <=