Storing data in the app sandbox - what if the user runs out of space?
I am storing some images locally in my app's sandbox. I currently have the minimum set at 10MB, and will be allowing the user to choose how much storage is allowed (up to 500MB).
In the scenario that the app is installed on a device where there's simple no space开发者_如何学运维 on it, or if there's 1MB space left and I start saving a 2MB image what happens?
Your save method will fail and throw an NSFileWriteOutOfSpaceError
.
If you handling a lot of disk space this might useful to you.
Edit:
To the space left, you can use this code:
NSDictionary *fsAttr = [ [NSFileManager defaultManager] fileSystemAttributesAtPath:NSTemporaryDirectory()];
NSNumber *totalFreeSize = [fsAttr objectForKey:NSFileSystemFreeSize];
精彩评论