Some prerequisites before you start to import SQLite database into Core Data
– whatever sqlite addon you use for your projects, the method expects an NSDictionary with keys (sqlite column names) and the corresponding values.
– ZAssert is provided by Marcus S. Zarra (www.cimgf.com)
Here are the rules the method counts on
1. with some exceptions (see below) core data entity properties/sqlite column name must have the same
2. the values stored in sqlite must be convertible to the datatype expected by core data
Name exceptions for core data properties
1. properties of type NSString with the name = exampleNormalized
You might want to store a string value with its normalized pendant for searching purposes. Here exampleNormalized uses a method of NormalizedStringTransformer to
convert a string into its normalized form.
[self setPrimitiveExampleNormalized:[NormalizedStringTransformer normalizeString:value]];
In that case the method will look for a sqlite key with the extension “Normalized” stripped off and will use that value to set exampleNormalized.
2. A property with a name exampleURI stores the persistent objects URI as string value. So it acts as a relationship without using the normal core data relationship
As those values can’t be provided by sqlite you have to prepare a separate dictionary (relations) containing the values.
3. NSDateAttributeType properties must end with the word “Time” respectively “Date”. For both values separate formatters can be used to convert the string value into an NSDate object.
If the method can’t find a corresponding sqlite value and the property is not optional an exception is raised.