0

ジャーナリング アプリケーションを作成しようとしており、Core Data からのエントリの削除に取り組んでいます。オブジェクトを削除しようとしても何も起こらず、エラー メッセージも何も表示されず、エントリはまだ存在し、削除されません。コード:

- (void)deleteButtonPressed:(UIButton *) button {
    NSLog(@"Button Pressed");
    NSLog(@"%i", button.tag);

    UIView *viewToRemove = [self.view viewWithTag:button.tag];
    [viewToRemove removeFromSuperview];

    UIView *secondViewToRemove = [self.view viewWithTag:button.tag];
    [secondViewToRemove removeFromSuperview];

    UIView *thirdViewToRemove = [self.view viewWithTag:button.tag];
    [thirdViewToRemove removeFromSuperview];

    UIView *fourthViewToRemove = [self.view viewWithTag:button.tag];
    [fourthViewToRemove removeFromSuperview];

    JournalrAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

    NSManagedObjectContext *context = [appDelegate managedObjectContext];

    NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Entrys" inManagedObjectContext:context];

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:entityDesc];

    NSManagedObject *matches = nil;
    NSError *error;
    NSArray *objects = [context executeFetchRequest:request error:&error];

    matches = objects[1];
    [context deleteObject:matches];

    if (![context save:&error]) {
        NSLog(@"Can't Delete! %@ %@", error, [error localizedDescription]);
        return;
    }
}
4

1 に答える 1