Вопрос

I like Core Data and have enjoyed how easy it makes simple database transactions. But I also have several complex queries that I need to do, and I fear that Core Data isn't going to make it easy to run those queries.

Here's are a couple examples of the kinds of queries I need to do (these are in MySQL but I'd adapt them later for SQLite, if necessary):

http://d.pr/n/h0mD

http://d.pr/n/ZVVx

So here are my questions:

  1. Will Core Data and its NSPredicates allow me to do all this stuff? (date constraints, if/else conditions, joins, group by, etc.)
  2. If this won't be possible (or doable with a reasonable amount of effort), can I use something like FMDB alongside of Core Data? (yes, I know I would have to be careful)

I look forward to your insights. Thanks!

Это было полезно?

Решение

you should not use FMDB with Core data. Technically, you can. But your app might break at some point. Apple does not guarantee the schema to be predictable. Core data is an abstraction, and the underlying persistent store is disconnected from core data. They even mentioned this on wwdc videos for 2013. You can generate the queries you are trying to get by using NSPredicate, NSExpression. You also can do some checkups on memory (if possible). I will look at your queries and see if I can generate

Другие советы

Core data is not a database. It's an object persistence model. If you are using it like a standard database then you're probably better off using FMDB.

Have a look here.

I learned this the hard way. You don't have to. =)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top