【问题标题】:Core Data, Fetch only 15 rows, and then the next 15 fetched on event trigger核心数据,仅获取 15 行,然后在事件触发时获取下 15 行
【发布时间】:2014-02-01 09:47:32
【问题描述】:

我在后端实现了分页,并从服务器获取单元格。

数据是分批次的,我必须检查,如果批次已经存在于数据库中,我不必从服务器获取。

要实现这一点,我只需要获取前 15 行,然后在事件触发器上获取下 15 行。

有什么办法吗?

[fetchRequest setFetchBatchSize:15];

当我们滚动时,上面的内容会自动获取。

【问题讨论】:

    标签: ios core-data nsfetchrequest


    【解决方案1】:

    首先将请求的 fetch 偏移设置为 0,并将 fetchLimit 设置为 15,然后每次将 15 添加到 fetchOffset...希望这会有所帮助

    // first fetch
    request.fetchOffset = 0;
    request.fetchLimit = 15;
    
    // second fetch
    request.fetchOffset = 15;
    request.fetchLimit = 15;
    
    // third fetch
    request.fetchOffset = 30;
    request.fetchLimit = 15;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 1970-01-01
      • 2018-07-09
      • 1970-01-01
      • 1970-01-01
      • 2020-02-04
      • 2022-11-21
      相关资源
      最近更新 更多