• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
newbie coredata NSManagedObjectModel empty
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

newbie coredata NSManagedObjectModel empty


  • Subject: newbie coredata NSManagedObjectModel empty
  • From: Jonathan Saggau <email@hidden>
  • Date: Wed, 12 Oct 2005 20:31:28 -0400

Hi folks

Teaching myself core data and objective-C at the same time.

I'm trying to instantiate a NSManagedObjectModel and, while the code
compiles with no errors (other than test kit errors), I think no
NSManagedObjects are making their way into the model. ((I hope I'm using the
right vocabulary here.))

I'm using the octest // SenTestingKit.framework to exercise custom
NSManagedObject classes.

1. I put a breakpoint in the custom NSManagedObject class and, though those
classes are apparently instantiated and messaged without error, the methods
are not run as I expect (my breakpoint doesn't get hit).
2. I tried to take my custom NSManagedObject class out of the picture and
just use the xcdatamodel directly. Same behavior.

When I print out the representation of the NSManagedObjectModel it is always
the same:

(NSManagedObjectModel) isEditable 0, entities {}, fetch request templates {}

I haven't been on this list (or using cocoa) for long, so please excuse me
if I'm about to include an improperly large amount of code and output.

Jonathan

code:

- (void) testOrchestraLocal
{

NSArray *bundlesToSearch = [NSArray arrayWithObject:[NSBundle mainBundle]];
NSManagedObjectModel *model = [[NSManagedObjectModel
mergedModelFromBundles:bundlesToSearch] retain];
NSLog(@"the Initial mom model is described as \n%@",model);

NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator
alloc] initWithManagedObjectModel:model];
NSManagedObjectContext *context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:coordinator];

NSLog(@"the Initial mom model is described as \n%@",model);
NSManagedObject *orch = [NSEntityDescription
insertNewObjectForEntityForName:@"Orchestra"
inManagedObjectContext:context];

NSLog(@"the after orchestra mom model is described as \n%@",model);

NSString *nameString = [orch valueForKey: @"nameString"];

NSLog(@"YOU JS!! 1st nameString = %@",nameString);
NSLog(nameString);

STAssertEquals(@"New Orchestra", nameString,
@"Default Orchestra nameString was WRONG, man");

[orch setValue:@"THE NEW NAME"
forKey:@"nameString"];

NSString *newNameString = [orch valueForKey: @"nameString"];

STAssertEquals(@"THE NEW NAME" , newNameString,
@"Default Orchestra nameString was WRONG, man");

NSLog(@"YOU JS!! 2nd nameString = %@",newNameString);
NSLog(newNameString);

[orch release];
[context release];
[model release];
}

ERRORS:
/Volumes/Docs/Users/jonathan/svnCheckouts/OrchestrationTool/trunk/exerciseModel.m:151:
error: -[exerciseModel testOrchestra] : '2' should be equal to '0': Default
Orchestra a440Int should have been changed to 2, but was 0 instead!
/Volumes/Docs/Users/jonathan/svnCheckouts/OrchestrationTool/trunk/exerciseModel.m:77:
error: -[exerciseModel testOrchestraLocal] : '<000ae054 >' should be equal
to '<00000000 >': Default Orchestra nameString was WRONG, man
/Volumes/Docs/Users/jonathan/svnCheckouts/OrchestrationTool/trunk/exerciseModel.m:96:
error: -[exerciseModel testOrchestraLocal] : '<000ae060 >' should be equal
to '<00000000 >': Default Orchestra nameString was WRONG, man

gdb Output:
Test Suite
'/Volumes/Docs/Users/jonathan/build/Debug/testCases.octest(Tests)' started
at 2005-10-12 20:22:02 -0400
Test Suite 'exerciseModel' started at 2005-10-12 20:22:02 -0400
Current language: auto; currently objective-c
2005-10-12 20:22:16.710 otest[7266] the Initial mom model is described as
(NSManagedObjectModel) isEditable 0, entities {}, fetch request templates {}
2005-10-12 20:22:16.710 otest[7266] the after orchestra mom model is
described as
(NSManagedObjectModel) isEditable 0, entities {}, fetch request templates {}
2005-10-12 20:22:20.620 otest[7266] YOU JS!! 1st nameString = (null)
/Volumes/Docs/Users/jonathan/svnCheckouts/OrchestrationTool/trunk/exerciseModel.m:77:
error: -[exerciseModel testOrchestraLocal] : '<000ae054 >' should be equal
to '<00000000 >': Default Orchestra nameString was WRONG, man
/Volumes/Docs/Users/jonathan/svnCheckouts/OrchestrationTool/trunk/exerciseModel.m:96:
error: -[exerciseModel testOrchestraLocal] : '<000ae060 >' should be equal
to '<00000000 >': Default Orchestra nameString was WRONG, man
2005-10-12 20:22:22.790 otest[7266] YOU JS!! 2nd nameString = (null)
Test Case '-[exerciseModel testOrchestraLocal]' failed (20.494 seconds).

--
The extent to which an individual can resist being blindly led by tradition
is a good measure of his vitality. - Harry Partch

There is a computer disease that anybody who works with computers knows
about. It's a very serious disease and it interferes completely with the
work. The trouble with computers is that you 'play' with them! - Richard P.
Feynman
 _______________________________________________
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

  • Prev by Date: Re: Making all components in path
  • Next by Date: Re: Bindings and Core Data question.
  • Previous by thread: Re: Making all components in path
  • Next by thread: RE: newbie coredata NSManagedObjectModel empty
  • Index(es):
    • Date
    • Thread