Import data using MagicalRecord

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.

Core data model

Plate structure

enter image description here

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"
    }
]
+5
source share
1 answer

The problem, it seems like an error in MagicalRecord, has discovered an open error for this problem.

MR_importFromArray: MR_saveWithBlock: saveWithBlockAndWait:.

+2

All Articles