magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

How to Find weather the DB is Full Using Magical records #1191

Open Arunchaitanya35 opened 8 years ago

Arunchaitanya35 commented 8 years ago

We were using Magical record for parsing data to DB ....... We have a query that how to find weather the Core Data stack is full or not ....or is there any block that returned error when the DB stack is Full

tonyarnold commented 8 years ago

I'm not sure what you mean by "full"? If the storage device that one of your persistent stores is full, you should receive an appropriate error when trying to save (although you'd be seeing errors and warnings from the OS at this point).

Arunchaitanya35 commented 8 years ago

I mean that I need to identify whether device memory is full or not before inserting any data to my coredata object using Magical Record SDK. Generally we will have SQLite entities to know the status like SQLite_OK, SQLIte_FULL etc but MagicalRecords does't log them. Could you please let me know how can we retrieve these codes using MagicalRecord queries.

tonyarnold commented 8 years ago

CoreData might use SQLite behind the scenes, but it exposes very little of SQLite's real API. There is no check for this in MagicalRecord, and to my knowledge there is no check for this in CoreData either.

Most of Cocoa is designed around the idea that you attempt and action and gracefully handle the error. So try inserting the data — the framework will return NSError instances on save if there are issues.

How big is the data you're dealing with that you'd even be concerned about memory being full? If that's an actual concern, you may need to look at breaking the insert of the data down into smaller chunks so that CoreData has time to save the changes off to disk (and out of memory) before importing the next batch of data.