I'm trying to get the free space on the device and the amount of space my sandbox is using. Any thoughts?
Thanks, Rick
In Objective-C you can get the available file system space with NSFileManager
:
NSFileManager* filemgr = [NSFileManager defaultManager];
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [paths objectAtIndex:0];
NSDictionary* fsAttr = [filemgr attributesOfFileSystemForPath:docDirectory error:NULL];
unsigned long long freeSize = [(NSNumber*)[fsAttr objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
To get the amount of space your app is using read this question: Calculate the size of a folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With