Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Core data and disk space

Does anyone know what happens if you try to save to core data, but there is not enough disk space left?

I'm assuming the save operation generates an NSError of some kind? How would you tell it was a disk space error not some other error during disk write?

like image 524
nsx241 Avatar asked Jan 20 '12 22:01

nsx241


2 Answers

After a few hours of trying to fill up the disk, I've found that the error you get is:

NSSQLiteErrorDomain = 13;
NSUnderlyingException = "error during SQL execution : database or disk is full";

It is rather difficult to get this error:

  • iOS devices claim to be full before they really are. I managed to squeeze an extra 206MB onto an iPod that claimed to have 0 bytes free.
  • As the device fills up, it automatically starts deleting caches and other temporary files.
like image 97
Ant Avatar answered Nov 20 '22 11:11

Ant


This seems to be a poor choice by the CoreData developers when implementing their Error handling API. instead of defining a NSCoreDataErrorDomain they're overloading NSCocoaErrorDomain and passing up SQLite error codes defined here.

like image 39
rudy Avatar answered Nov 20 '22 11:11

rudy