Expected specifier-qualifier-list before 'NSManagedObjectModel' error and how to fix it

I was putting Core Data into an existing application. I was cutting and pasting a lot from the excellent Apple example, iPhoneCoreDataRecipes. No, this is not a bunch of code examples to show you how to get started with Core Data...but it is a working example of how to get an app up and running with Core Data using SQLite as a back-end persistent store.

So, I was happily cutting and pasting code between iPhoneCoreDataRecipes and my iPhone app (the premium version of FindIt, if you must know) when I ran into the following error everywhere:

Expected specifier-qualifier-list before 'NSManagedObjectModel'


The object changed (i.e. it was not always 'NSManagedObjectModel') but the error was consistent. And yet I was copying everything over from the .m and .h files in the Apple example. Strange.

My first thought was checking that I had included the Core Data framework in the app. Yup. That wasn't it.

Then I realized--it was the global prefix file. I went and checked out the Apple example, and sure enough, Core Data was there. I just needed to through this into my _Prefix.pch file as well, and all the errors went away.

Hope this helps you too!

2 comments:

pbohrer said...

Thanks. I had the same problem.

SuperSam said...

Good work, sorted it out a treat!

Post a Comment