Datos básicos: recuperar todas las entidades

I want to know is there an equivalent to the MySQL SELECT * FROM table ORDER BY sth to fetch all the results.

preguntado el 09 de enero de 11 a las 11:01

2 Respuestas

Usa una NSFetchRequest con un nil predicate and an appropriate NSSortDescriptor. On iOS, you should be using an NSFetchedResults controller as the query may return more items that you want in memory at once.

Respondido el 10 de enero de 11 a las 17:01

CoreData on iOS is pretty smart about memory utilization. It will not load all of your rows into the returned NSArray. Actually, the object returned is a subclass of NSArray that is a proxy of an array, meaning that it implements all of the methods of NSArray, but doesn't actually have an array under the covers. It will only load the data rows as requested by the app. - Jack Cox


The 'grammar' may be equivalent but there is some work you have to do in the application. A good starting explanation is Aquí.

In general you'd want to setup a NSFetchRequestwith the appropriate filters, sorts, etc. that you need.

-- Frank

Respondido el 09 de enero de 11 a las 14:01

thanks for the answer. seems a NSFetchRequest sin un NSPredicate works. I'm still testing. - xhan

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.