Write native SQL in Core Data

前端 未结 3 869
别那么骄傲
别那么骄傲 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:50

    This is a bit of a hack, but... The SQLite library is capable of opening more than one database file at a given time. It would be quite feasible to open the Core Data DB file (read/only usage) directly with SQLite and open a second file in conjunction with this (reporting/temporary tables). One could then execute direct SQL queries on the data in the Core Data DB and persist them into a second file (if persistence is needed).

    I have done this sort of thing a few times. There are features available in the SQLite library (example: full-text search engine) that are not exposed through Core Data.

提交回复
热议问题