且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多个异步请求以在目标c中创建动态表视图

更新时间:2023-11-30 20:27:22

您应该保留影子数据结构表格视图-您的数据模型。当您输入异步数据来更新模型时,请分派一个块以更新主线程上的UI。

You should keep a shadow data structure of your table view - your data model. When your asynchronous data comes in update the model, then dispatch a block to update the UI on the main thread.

UI更新方法向表视图询问数组的数组。可见细胞。它将这些与数据模型进行比较(使用适当的锁),然后根据需要更新单元格内容。

The UI update method asks the table view for the array of visible cells. It compares these to the data model (with proper locks) and then updates cell content as needed.

通过使用表格部分,您可以更轻松地确定何时插入或删除单元格。

By using table section you may have an easier time determining when to insert or delete cells.

用户滚动查看您经常查看模型的表以显示哪些内容。

When the user scrolls the table you always look at the model for what content to display.