My goal is to create a sqlite database and fill it with data (probably 1000+ rows) and use this database to pre load core data, and fill a table view.
So far I have the table view working with Core Data, Managed Object Models. I can add items and remove items - basically I have the Master-Detail template working but with my own model.
The Question: How do I create a sqlite database in the correct format for use with Core Data?
I have successfully done this using provided sql databases and tutorials from books. What I noticed is that the table 'fugitive' (for example) in my tutorial is written 'ZFUGITIVE' in the provided sqlite database. All of its columns have the 'Z' appended to the front ('ZFUGITIVEID', 'ZNAME'...) and three extra columns ('Z_PK', 'Z_ENT', 'Z_OPT') exist that are not included in the managed object model (.xcdatamodeld). Besides the 'Z' all caps names and extra columns I also see (in this .sqlite db that came with a tutorial) that there are two extra tables 'Z_PRIMARYKEY' and 'Z_METADATA'.
Im familiar with the sqlite terminal commands and can create a database but it does not have the correct formatting, extra rows or extra tables with metadata. What I had done as an experiment is take the above Fugitive sqlite database table and added another table to it. At first I called it table 'thing' with columns 'thingID' and 'title'. I created the managed object for it and connected it to my table view. I could not for the life of me get the data to preload in core data / my table view. I received No error messages, it just didn't pre load data (It did let me add and remove new items just like the Master-Detail template).
So I renamed table 'thing' to 'ZTHING' with columns ('Z_PK', 'Z_ENT', 'Z_OPT', 'ZTHINGID' and 'ZTITLE') and now I get the following error message. I know that its telling me I created my table improperly however I cant find documentation on how to create it correctly. Please help.
Here is the big honking Error that basically states the version number recorded in table Z_METADATA (column Z_UUID) is incorrect: [Or so I think]
Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x5b489c0 {metadata=<CFBasicHash 0x5b4e960 [0x2651380]>{type = immutable dict, count = 7,
entries =>
2 : <CFString 0x5b4ea40 [0x2651380]>{contents = "NSStoreModelVersionIdentifiers"} = <CFArray 0x5b4eb10 [0x2651380]>{type = immutable, count = 0, values = ()}
4 : <CFString 0x5b4ea90 [0x2651380]>{contents = "NSPersistenceFrameworkVersion"} = <CFNumber 0x5b4e530 [0x2651380]>{value = +248, type = kCFNumberSInt64Type}
6 : <CFString 0x5b4eac0 [0x2651380]>{contents = "NSStoreModelVersionHashes"} = <CFBasicHash 0x5b4eba0 [0x2651380]>{type = immutable dict, count = 1,
entries =>
1 : <CFString 0x5b4eb30 [0x2651380]>{contents = "Fugitive"} = <CFData 0x5b4eb50 [0x2651380]>{length = 32, capacity = 32, bytes = 0xe33370b6e7ca3101f91d25951e8bfe01 ... 9e50237bb313d390}
}
7 : <CFString 0x1ee464 [0x2651380]>{contents = "NSStoreUUID"} = <CFString 0x5b4e850 [0x2651380]>{contents = "E711F65F-3C5A-4889-872B-6541E4B2863A"}
8 : <CFString 0x1ee324 [0x2651380]>{contents = "NSStoreType"} = <CFString 0x1ee2e4 [0x2651380]>{contents = "SQLite"}
9 : <CFString 0x5b4ea10 [0x2651380]>{contents = "NSStoreModelVersionHashesVersion"} = <CFNumber 0x5d0b520 [0x2651380]>{value = +3, type = kCFNumberSInt32Type}
10 : <CFString 0x5b4eaf0 [0x2651380]>{contents = "_NSAutoVacuumLevel"} = <CFString 0x5b4ebf0 [0x2651380]>{contents = "2"}
}
, reason=The model used to open the store is incompatible with the one used to create the store}, {
metadata = {
NSPersistenceFrameworkVersion = 248;
NSStoreModelVersionHashes = {
Fugitive = <e33370b6 e7ca3101 f91d2595 1e8bfe01 3e7fb4de 6ef2a31d 9e50237b b313d390>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
);
NSStoreType = SQLite;
NSStoreUUID = "E711F65F-3C5A-4889-872B-6541E4B2863A";
"_NSAutoVacuumLevel" = 2;
};
reason = "The model used to open the store is incompatible with the one used to create the store";
}
Thank you so much for all help you can give me