Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
SELECT SUM(distance) WHERE type = 'TYPE1' 如何使用 Core Data 进行此查询?PS:为什么苹果不支持原生SQL语句?Core Data 的方式比必要的复杂,尤其是那些奇怪的类和函数。
SELECT SUM(distance) WHERE type = 'TYPE1'
Core Data 不是数据库。它是Apple预先编写的代码的模型层。对于您手头的问题,开发一个更简单的查询来检索满足类型条件的所有对象,然后总结代码中所有对象的距离值。在使用核心数据时,不鼓励进行类似 sql 的计算。