FMDB 检查是否为空方法并向前分离

FMDB check if empty method and move forward separation

在 FMDB 中,next 函数(如 if a!.next {} 中)既检查是否有另一行,也检查是否有另一行,我们可以单独做这些事情吗?检查是否还有另一行?

我看过文档,但是好像没有这种直接的方法。

next method in FMDB is simply a wrapper around the sqlite3_step函数。您可能习惯于将 "advance the recordset's cursor" 和您在其他环境中看到的 "EOF test" 的函数分开,但这正是 SQLite 的做法。

所以,不幸的是,不,SQLite 并没有真正为 "is there another row" 和 "retrieve the next row" 提供单独的函数。它是一个函数,sqlite3_step, which is called by FMDB's next, that serves both purposes. See the SQLite C interface API 用于 SQLite 函数的完整列表。

也许 FMDB 使用名为 FMRecordSet 的 class 会引起这种混淆,但我们必须记住,它实际上只是 SQLite C API 的一个薄包装。它仅限于 API 中固有的相同功能。