Rufen Sie mich an +49 151 20 43 62 02|

Import SQLite Database into Core Data

Home/Development/Import SQLite Database into Core Data

Import SQLite Database into Core Data

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 (

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.
- (void)setExampleNormalized:(id)value
[self willChangeValueForKey:@"exampleNormalized"];
[self setPrimitiveExampleNormalized:[NormalizedStringTransformer normalizeString:value]];
[self didChangeValueForKey:@"exampleNormalized"];

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.


By | 2015-12-12T13:10:11+00:00 Montag, März 21st, 2011|Development|0 Comments

About the Author:

Leave A Comment