[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GDL2] custom class creation
From: |
David Ayers |
Subject: |
Re: [GDL2] custom class creation |
Date: |
Mon, 03 Mar 2008 15:46:29 +0100 |
User-agent: |
Mozilla-Thunderbird 2.0.0.9 (X11/20080110) |
Hello Blake
Blake Nicholson schrieb:
(Note: I originally sent this to help-gnustep, but my message neither
went through nor bounced. I apologize in advance if people end up
receiving duplicates.)
I, for one, didn't receive it.
From what class should custom enterprise objects inherit, NSObject or
EOGenericRecord?
Well technically both should work.
I've tried both ways and have not been successful
running the following code snippet:
job = [[ESJob alloc] init];
[job setStyle:8];
[ec insertObject:job];
[ec saveChanges];
NSLog(@"%@", [jobDS fetchObjects]);
where ec is my EOEditingContext and jobDS is an EODatabaseDataSource for
the ESJob entity (I followed the setup in the GDL2 examples).
It's been a while... where exactly did we hide these examples? They
don't seem to be in svn. I remember that some old examples were
incorrect due to buggy GDL2 implementation at the time.
When I
inherit from EOGenericRecord, the code fails when saving changes and
gives the output I copied in below. When ESJob inherits from NSObject,
the code fails when I attempt to fetch the objects (Bus error).
I am running OS X (Leopard) and am using the sources from svn (the
revision I'm working with is 26179 for make, baseadd, and gdl2). My
library combo is apple-apple-apple. I've included the interface and
implementation files for my ESJob class that inherits from NSObject
below the error output I've received. If you need any other info,
please let me know.
[snip]
*** Error when ESJob inherits from EOGenericRecord ***
2008-03-03 01:35:52.710 test[33391:10b] *** Assertion failure in
-[EODatabase entityForObject:], EODatabase.m:321
2008-03-03 01:35:52.734 test[33391:10b] No object entity name for object
<ESJob 0x42f530 : classDescription=(null)
values={
}> of class ESJob (No object entity name for object <ESJob 0x42f530 :
classDescription=(null)
values={
}> of class ESJob)
This seems to indicate that the EOModel containing the EOEntity for
ESJob wasn't found. Maybe you could send me the eomodel files (or a
small project tarball) privately and I can have a look this evening.
In general we create new instances of enterprise objects with:
<code compiled="NO"; tested="NO";>
EOEntity *entity = [[EOModelGroup defaultGroup] entityNamed: @"ESJob"];
EOClassDescription *cd = [entity classDescriptionForInstances];
job = [cd createInstanceWithEditingContext: ec
globalID: nil
zone: NULL];
[ec insertObject:job];
[ec saveChanges];
</code>
This will insure the invocation of all the initialization methods which
are part of the GDL2 API are invoked.
WRT inheriting from NSObject vs. EOGenericReocord:
GDL2 tries to replace some of the KVC methods at runtime to mirror the
semantics of WebObjects 4.5. This method/category swiziling was
developed with GNU runtime and gnustep-base. AFAIR we had /some/
success on OS X with the Apple runtime and Foundation at the time. But
that's a few years back so I can easily imagine that either
a) we didn't / couldn't catch all the tricky semantics
b) we are subject to bit-rot.
Cheers,
David