discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GDL2] custom class creation


From: Blake Nicholson
Subject: [GDL2] custom class creation
Date: Mon, 3 Mar 2008 07:32:00 -0500

(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.)

From what class should custom enterprise objects inherit, NSObject or EOGenericRecord? 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). 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.


Thank you,
Blake


*** 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)
2008-03-03 01:35:52.738 test[33391:10b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No object entity name for object <ESJob 0x42f530 : classDescription=(null)
values={
}> of class ESJob'
2008-03-03 01:35:52.772 test[33391:10b] Stack: (
   2487029492,
   2479961964,
   2487029252,
   2477370852,
   1983600,
   2063704,
   959276,
   962008,
   1056412,
   11572,
   10536
)
Trace/BPT trap


*** ESJob.h ***
#import <Foundation/Foundation.h>

@interface ESJob : NSObject {
        int _style;
        ESJob *_previous;
        ESJob *_next;

}
- (int)style;
- (void)setStyle:(int)aStyle;
- (ESJob *)previous;
- (void)setPrevious:(ESJob *)prevJob;
- (ESJob *)next;
- (void)setNext:(ESJob *)nextJob;
@end

*** ESJob.m ***
#import "ESJob.h"

@implementation ESJob
- (int)style
{
        return _style;
}

- (void)setStyle:(int)aStyle
{
        [self willChangeValueForKey:@"style"];
        _style = aStyle;
        [self didChangeValueForKey:@"style"];
}

- (ESJob *)previous
{
        return _previous;
}

- (void)setPrevious:(ESJob *)prevJob
{
        [self willChangeValueForKey:@"previous"];
        [_previous autorelease];
        _previous = [prevJob retain];
        [self didChangeValueForKey:@"previous"];
}

- (ESJob *)next
{
        return _next;
}

- (void)setNext:(ESJob *)nextJob
{
        [self willChangeValueForKey:@"next"];
        [_next autorelease];
        _next = [nextJob retain];
        [self didChangeValueForKey:@"next"];
}

@end






reply via email to

[Prev in Thread] Current Thread [Next in Thread]