iphone - 直接从 NSFetchedResultsController 获取

标签 iphone core-data uitextview nsfetchedresultscontroller

我有一个 View Controller ,用于将核心数据模式中的数据填充到 UITableView 中,在 tableViewDidSelectRowAtIndexPath 委托(delegate)方法中,我初始化了另一个 View Controller 并将各个数据显示到 TextView 中。我的初始化 View Controller 的代码如下所示,

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    myViewController=[[MyViewController alloc] initWithManagedObject:[self.fetchedResultsController objectAtIndexPath:indexPath] parentViewController:self];
    myViewController.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:myViewController animated:YES];
    [transcribedTextViewController release];
    }
}

现在,在新的 View Controller 中,我用来填充上面传递的模型中的数据来填充 UITextView。但我确实有一个下一个和上一个按钮,我想使用我拥有的托管对象访问 fetchedResultsController,这可以简单地通过使用parentViewController 来完成。但我如何获取下一个数据。我想在下一个按钮上获取下一个数据。是否可以直接从新的 View Controller 增加 NSIndexPath 并使用它来获取模式。 请推荐我。

最佳答案

如果将对 fetchedResultsController 的引用发送到 myViewController,您可以通过创建新的 indexPath 来获取下一个对象(递增行) )并再次使用objectAtIndexPath。您必须首先检查是否确实存在下一个对象。如果涉及到部分,那就更复杂了。

如果您不想传递fetchedResultsController,您可以在核心数据对象之一中找到对其的引用(不记得是哪个)。

关于iphone - 直接从 NSFetchedResultsController 获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6007987/

相关文章:

ios - NSBatchDeleteRequest 导致合并冲突

ios - textView.typingAttributes 不适用于预测

iphone - iPhone应用程序商店批准-Coredata设计更改

iphone:应用内购买错误

ios - 从属性建立核心数据关系的最快方法是什么?

ios - 多用户的最佳实践 : Core Data or NSUserDefaults

ios - 编辑时 UITextView 光标完全消失

iphone - 如何在 iPhone OS 4 的数字键盘上显示按钮 ‘Done’?

iphone - 如何释放定义为属性的 IBOutlet?

iphone - 帮助我 - 打印全局 nsstring 变量时应用程序崩溃