I am using MagicalRecord to import data from plist. I use less import code, as described in this lesson. Importing data is simplified .
I have two manufacturers and a car, they have a one-to-many and one-to-one relationships, respectively.

Plate structure

This import works great
NSArray *manufacturers = ...
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
[manufacturers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[Manufacturer MR_importFromObject:obj inContext:localContext];
}];
} completion:^(BOOL success, NSError *error) {
}];
But it is not imported
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
[Manufacturer MR_importFromArray:manufacturers inContext:localContext];
} completion:^(BOOL success, NSError *error) {
}];
Any explanation would be highly appreciated.
EDIT: Array Manufacturers Magazine
[
{
"Cars": [
{
"CarID": 1,
"Name": "Civic"
},
{
"CarID": 2,
"Name": "Jazz"
},
{
"CarID": 3,
"Name": "City"
}
],
"ManufacturerID": 1,
"Name": "Honda"
}
]
source
share