核心数据与表视图

发布于 2024-12-27 14:24:39 字数 883 浏览 4 评论 0原文

我使用故事板和核心数据,我的全部内容正在数据库中更新,但当涉及到我的 fetchedrequestcontroller 时,没有反映在我的表视图中,并且设置了实体,它崩溃了任何线索,说明为什么我发布下面的代码,感谢您的帮助。

-(NSFetchedResultsController *)fetchResultsController
{
    if(fetchResultsController != nil)
    {
        return fetchResultsController;
    }

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Persons" inManagedObjectContext:self.managedObjectContext];

    [fetchRequest setEntity:entity];

    NSFetchedResultsController *afetchresultscontroller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
    afetchresultscontroller.delegate = self;
    self.fetchResultsController = afetchresultscontroller;

    return fetchResultsController;
}

im using storyboard and core data my entires are being updated in the database but not being reflected in my tableview when it comes to my fetchedrequestcontroller n ans sets the entity it crashes any clue as to why im posting the code below thanks for any help.

-(NSFetchedResultsController *)fetchResultsController
{
    if(fetchResultsController != nil)
    {
        return fetchResultsController;
    }

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Persons" inManagedObjectContext:self.managedObjectContext];

    [fetchRequest setEntity:entity];

    NSFetchedResultsController *afetchresultscontroller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
    afetchresultscontroller.delegate = self;
    self.fetchResultsController = afetchresultscontroller;

    return fetchResultsController;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混吃等死 2025-01-03 14:24:39

您发布的代码看起来不错。

发布崩溃的堆栈跟踪,以便有人进一步帮助您。

The code you posted looks fine.

Post the stack trace of the crash for someone to assist you further.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文