ios - 从 coredata (Swift) 返回行数
问题描述
我正在尝试将UITableView
保存到 coredata 的 a 中的一些图像传递给 a UICollectionView
,它不是 coredata 的一部分。
我希望 of 的返回计数numberOfItemsInsection
应该UICollectionView
等于 的总行数UITableView
。如何访问 的行数UITableView
?
解决方案
您可以访问 tableview numberOfRows 为:
tableView.numberOfRows(inSection: [//Section No])
您可以从 Coredata 获取 numberOfRows 为:
func getRecordsCount() {
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: _entityName)
do {
let count = try context.count(for: fetchRequest)
print(count)
} catch {
print(error.localizedDescription)
}
}
推荐阅读
- sql - 如何计算每个产品每天的库存给定天数在 PostgreSQL 之间缺失?
- c# - Identity Server 4 向用户添加自定义声明
- xml - 在 Snowflake 中解析嵌套的 XML
- python - Matplotlib 标签更改灰色阴影
- angular - ngrx 中的 StoreModule.forRoot 引发角度错误
- vba - VBA 宏报告 PowerPoint 幻灯片上的链接
- sql - 如何使用 XMLQuery 更新 clob Oracle 中的 XML 属性
- flutter - 无法在点击按钮时关闭 Flushbar(Flushbar 是 Flutter 的一个包)
- python - 将带有重复标签的 XML 转换为 JSON
- python - 读取txt文件时将带空格的名称(国家名称)视为多列