Domanda

When i simply call MR_createEntity, i get an exc_bad_access error. As i'm new to magicalRecord, I can't find where the bug is coming from.

The code :

TMTAppDelegate.m

//TMTAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    [MagicalRecord setupAutoMigratingCoreDataStack];



    NSArray *trajetsRawArray = @[@{@"km" : @125, @"mn":@110, @"adressStart" : @"Metz", @"adressEnd" : @"Gérardmer", },
                                 @{@"km" : @4, @"mn":@14, @"adressStart" : @"Plappeville", @"adressEnd" : @"Metz"},
                                 @{@"km" : @312, @"mn":@200, @"adressStart" : @"Metz", @"adressEnd" : @"Paris"},
                                 @{@"km" : @413, @"mn":@236, @"adressStart" : @"Marseille", @"adressEnd" : @"Toulouse"},
                                 @{@"km" : @2, @"mn":@4, @"adressStart" : @"Ban-St-Martin", @"adressEnd" : @"Metz"},
                                 @{@"km" : @65, @"mn":@63, @"adressStart" : @"Metz", @"adressEnd" : @"Gérardmer"}
                                 ];

    //[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"backButton"]];
    self.trajetsManager = [[TMTTrajetsManager alloc]initWithArray:trajetsRawArray];
    NSLog(@"hello");
    return YES;
}

TMTTrajetsManager.m

//  TMTTrajetsManager.m
-(id)initWithArray:(NSArray *)array {

    self = [super init];
    if (self){
        for (NSDictionary *trajetDico in array){

            Trajet *trajet = [Trajet MR_createEntity];
            trajet.distance = [trajetDico objectForKey:@"km"];
            trajet.duration = [trajetDico objectForKey:@"mn"];
            trajet.start_point = [trajetDico objectForKey:@"adressStart"];
            trajet.end_point = [trajetDico objectForKey:@"adressEnd"];
            self.autoManager = [[TMTTrajetAutoManager alloc] initWithDelegate:self];
        }
    }

    return self;
}

The error :

enter image description here

È stato utile?

Soluzione

Disable MR_SHORTHAND, and use the method names with the MR_ prefix explicitly. It looks like the this method is recognizing that this method exists via the shorthand support. Shorthand support is now deprecated and will be removed in the next version of MagicalRecord.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top