简体   繁体   English

从核心数据中获取并显示在swift 5中的tableview中

[英]Fetch from core data and display it in tableview in swift 5

How to fetch saved data from core data?如何从核心数据中获取保存的数据? How to debug it?如何调试呢? I have called the fetch from view will appear..我已经调用了视图中的提取将出现.. 在此处输入图像描述

在此处输入图像描述

How to fetch saved data from core data?如何从核心数据中获取保存的数据? How to debug it?如何调试它? I have called the fetch from view will appear..我已经调用了从视图中提取将出现.. 在此处输入图像描述

在此处输入图像描述

As per your comments on Ashish's response, it seems like you are not saving the managed object context after inserting the records.根据您对 Ashish 回复的评论,您似乎在插入记录后没有保存托管 object 上下文。

Insertion process:插入过程:

  1. Fresh launch app, initialize core data and insert data in DB全新启动应用程序,初始化核心数据并将数据插入数据库
  2. Call managedObjectContext.save and check if the save operation is successful or got failure.调用 managedObjectContext.save 并检查保存操作是成功还是失败。

Then notify the view controller to refresh the weather list using NSNotification on the main thread or some other mechanism as per your suitability.然后通知视图 controller 使用主线程上的 NSNotification 或其他机制根据您的适用性刷新天气列表。

And then try to fetch weathers from viewContext for UI rendering.然后尝试从 viewContext 中获取天气以进行 UI 渲染。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Swift 4的核心数据对TableView中的数据进行分组 - Grouping Data in TableView from Core Data in Swift 4 如何从存储在tableView的Core数据中的用户数组中获取并显示不同的用户数据? - How to fetch and display different user data from array of users stored in Core data in tableView? 我正在尝试使用NSFetchedResultController从核心数据中获取对象,但它在tableview中不显示任何数据 - I am trying to fetch objects from core data using NSFetchedResultController but it does not display any data in tableview 如何在Swift中从核心数据中获取NSSet - How to fetch NSSet from Core Data in Swift 如何使用Swift从Core Data获取组 - How to fetch as group from Core Data with Swift 快速从核心数据中获取特定的uiimage - swift fetch a specific uiimage from core data 如何在自定义TableView单元格中显示来自Core Data数据库的数据? - How to display data from Core Data database in custom TableView Cells? 按日期从核心数据中对TableView进行排序-Swift4 - Sort TableView by Date from core Data - Swift4 如何快速显示来自数组数组的tableview单元格中的数据 - How to display the data in the tableview cell from the array of array in swift 如何仅从Web提取数据后才显示tableView? (迅速) - How to display tableView only after data fetched from web? (Swift)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM