0

我有这个函数在两个地方返回一个 SIGTRAP。

- (void)addShindy:(UIBarButtonItem *)sender
{
    AddShindyViewController *addShindyViewController = [[AddShindyViewController alloc] initWithNibName:@"AddShindyViewController" bundle:nil];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addShindyViewController];

    addShindyViewController.delegate = self;

    NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
    [addingContext setParentContext:[self.fetchedResultsController managedObjectContext]];
    // SIGTRAP occurring on line above this

    Shindy *shindy = (Shindy *)[NSEntityDescription insertNewObjectForEntityForName:@"Shindy" inManagedObjectContext:addingContext];
    addShindyViewController.shindy = shindy;
    addShindyViewController.managedObjectContext = addingContext;

    [self presentViewController:navController animated:YES completion:nil];
}

我怀疑该错误与“添加上下文”有关,因为引发错误的两行都有共同点。

如果有人需要,我可以发布更多代码。

4

0 回答 0