Write native SQL in Core Data

前端 未结 3 915
别那么骄傲
别那么骄傲 2021-01-22 19:15

I need to write a native SQL Query while I\'m using Core Data in my project. I really need to do that, since I\'m using NSPredicate right now and it\'s not efficien

3条回答
  •  自闭症患者
    2021-01-22 19:44

    If you want to use Core Data there is no supported way to do a SQL query. You can fetch specific values and use [NSExpression expressionForFunction:arguments:] with a sum: function.

    To see what SQL commands Core Data executes add -com.apple.CoreData.SQLDebug 1 to "Arguments Passed on Launch". Note that this should not tempt you to use the SQL commands youself, it's just for debugging purposes.

提交回复
热议问题