You problem is that your trying to load your model file from the path to an SQL persistent store inside the app bundle. Stores and model files are two separate types of files with two separate functions. You can't initialize a NSManagedObjectModel instance from an SQL file and vice versa because the two file types hold completely different information You need to change the pathForResource: to look for the right file.
The file type is mom and the default name is the app name so you should use something like: NSString *modelPath = NSBundle mainBundle pathForResource:@"AppName" ofType:@"mom" (If you named you model something else, use that name. ) All this has nothing to do with importing an existing SQL file. However, you will need to fix this before importing the SQL as other's have suggested.
You problem is that your trying to load your model file from the path to an SQL persistent store inside the app bundle. Stores and model files are two separate types of files with two separate functions. You can't initialize a NSManagedObjectModel instance from an SQL file and vice versa because the two file types hold completely different information.
You need to change the pathForResource: to look for the right file. The file type is mom and the default name is the app name so you should use something like: NSString *modelPath = NSBundle mainBundle pathForResource:@"AppName" ofType:@"mom"; (If you named you model something else, use that name. ) All this has nothing to do with importing an existing SQL file.
However, you will need to fix this before importing the SQL as other's have suggested.
Ok that makes more sense. I changed the strings to my App name and mom, and now when the program crashes it gives me this error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -NSURL initFileURLWithPath:: nil string parameter' Which leads me to believe that it cannot find the mom file. Which is weird.
Heck I cant seem to find a mom file anywhere on my mac, so maybe core-data is not making such a file? – kevin Mendoza Sep 5 '10 at 3:26 In your project in code, you will have file with an extension of xcdatamodel (it's the one with you entity graph. ) The mom file in the build will have the same name as that file.
You can also use modelByMergingModels: which will automatically locate all the model files for you. – TechZen Sep 5 '10 at 10:59 I selected yours as the answer because it was the closest to what I found worked. It had to be pathForResource:@"AppName" ofType:@"momd" – kevin Mendoza Sep 5 '10 at 18:35 The momd is a versioned model file.
– TechZen Sep 5 '10 at 20:12.
If it is not created with Core Data then it is not going to work. Core Data can only read SQLite files that are created with Core Data.
I am getting it from the USGS website. What I am doing is loading it directly using sql statements in the application, creating objects out of that data, and then storing them in core data. – kevin Mendoza Sep 3 '10 at 6:14 So in effect I am not using coredata to read the populated database, but I am using coredata to store it in another database for future use in my program.
– kevin Mendoza Sep 3 '10 at 8:18.
From Apple's Core Data Development Guide: Compiling a Data Model A data model is a deployment resource. In addition to details of the entities and properties in the model, a model you create in Xcode contains information about the diagram—its layout, colors of elements, and so on. This latter information is not needed at runtime.
The model file is compiled to remove the extraneous information and make runtime loading of the resource as efficient as possible. The xcdatamodel "source" file is compiled into a mom deployment file using the model compiler, momc. In other words, Managed Object Models are "compiled" from Xcode Data Model "source" by Xcode during the build process, and that .
Mom file is placed inside the application bundle. So you may need to create a Data Model file manually. To work around this, I use a Core Data-savvy command line tool to pre-populate the SQLite database files I use with my iPhone projects.
Edit: If Mr. Zarra is correct (and he usually is), then you should write a command line tool in the manner I described, to open the existing database and then pre-populate a new SQLite database file with Core Data. It's a bit of a pain, but it will work.
I thought I already created a datamodel. I added an entity, and attributes to the datamodel, as well as a class specific for that entity as described in a core data tutorial. – kevin Mendoza Sep 2 '10 at 23:18 Check the application bundle in your build directory.Is there a .
Mom file present? (Right-click on Target, Reveal in Finder, right-click on . App, Show Package Contents) If not, and you're sure you have an xcdatamodel, then make sure the xcdatamodel file is listed under the "Compile Sources" section of your Target.
– Shaggy Frog Sep 2 '10 at 23:43 Right clicking on the target on xcode does not bring up a reveal in finder option. However searching through my computer's files I could not find a . Mom file.
– kevin Mendoza Sep 3 '10 at 6:22 Right click on the target, and you will get the menu I described. – Shaggy Frog Sep 3 '10 at 6:46 as in the blue thing that bears the title of my app? Opening that in finder, and opening package contents shows only three files of extentions .
Mode1v3 , . Pbxuser , and . Pbxproj – kevin Mendoza Sep 3 '10 at 8:10.
In other words, Managed Object Models are "compiled" from Xcode Data Model "source" by Xcode during the build process, and that . Mom file is placed inside the application bundle. So you may need to create a Data Model file manually.
To work around this, I use a Core Data-savvy command line tool to pre-populate the SQLite database files I use with my iPhone projects. If Mr. Zarra is correct (and he usually is), then you should write a command line tool in the manner I described, to open the existing database and then pre-populate a new SQLite database file with Core Data. It's a bit of a pain, but it will work.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.