2010-11-30 78 views
0


我想通过一个NSInteger到一个tableView控制器,然后用它来设置一个徽章。
在这种情况下,我想通过的NSInteger是tableView中的行数,与Core Data一起返回(numberOfRows)。通过NSInteger到一个tableView控制器

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    NSInteger numberOfRows = 0; 

    if ([[fetchedResultsController sections] count] > 0) { 
     id NSFetchedResultsSectionInfo sectionInfo = [[fetchedResultsController sections] objectAtIndex:section]; 
     numberOfRows = [sectionInfo numberOfObjects]; 
    } 

    return numberOfRows; 
}

如何声明另一个NSInteger,然后将它传递给tableView控制器?

感谢,
马修

+0

不知道我是否正确理解了你的问题,但不是你只是使用上面的代码? – Rog 2010-11-30 21:52:08

+0

对不起,延迟...这段代码是我用在我的主控制器中,管理核心数据。我想将numberOfRows数字传递给另一个tableView控制器来设置一个方法...我尝试使用NSUserDefaults并且可以工作,但是每当表视图中的行数发生变化时,数字都不会更新...您能帮我吗? – matteodv 2010-12-01 13:31:29

回答

1

这听起来像你可能需要在第二个表视图控制器配备了两个读取的结果控制器。第一个FRC将管理表本身,第二个将计算第一个表中数据的现有行数。

您将不得不分配第二个tableview控制器作为两个FRC的委托,然后在委托方法中测试哪个控制器发起更改并采取适当的操作。

相关问题