small medium large xlarge

Back to: All Forums  Core Data
Generic-user-small
11 Mar 2010, 19:31
Knut E. Vonheim (10 posts)

Hi all!

Just went through the modification of -(NSManagedObjectModel *) managedObjectModel on page 68 of the p1.0 PDF. The code in the book replaces the default implementation of the method from the template.

The text says pathForResource:@”DataModel” while the template project names the model Grokking_Recipes_DataModel. Hence, following the text in the book will make path either x0x or nil, I think.

However, when I ran this with @”DataModel” the app crashed on NSAssert. How come? I cannot get NSAssert(path != nil, …..) to trigger.

For the record, I have also downloaded the latest version of the code, and I am on 10.6.2 and Xcode 3.2.1 running in 64-bit.

Any help, hints, or pointers are greatly appreciated!

TYIA!

Cheers,

Knut

Avatarsmall_pragsmall
11 Mar 2010, 20:04
Marcus S. Zarra (284 posts)

Depending on how you configure Xcode, the name of the file will differ. Therefore you need to change that string (@”DataModel”) to match the name of your data model.

Generic-user-small
11 Mar 2010, 20:22
Knut E. Vonheim (10 posts)

Hi Marcus!

Thank you for the quick response!

I figured out the data model name difference. But shouldn’t NSAssert trigger instead of crashing when a data model is not found?

TYIA!

Cheers,

Knut

Avatarsmall_pragsmall
11 Mar 2010, 20:40
Marcus S. Zarra (284 posts)

NSAssert does trigger a crash because it is a dev tool. That is expected behavior.

Generic-user-small
11 Mar 2010, 20:46
Knut E. Vonheim (10 posts)

Hi Marcus,

I kept on testing and reading the docs. Now it works and the description is printed in the debugger. This did not happen earlier. I didn’t really change anything except adding the path to the description/text as an argument and then it printed. Then I switched back to the text in the book and then that printed, too.

Go figure:-)

I appreciate the help you provide here! Sometimes a beginner goes a “little nuts” when the behavior of the code is not as intended or as expected.

Great book on a good topic!

Cheers,

Knut

You must be logged in to comment