Timur Mustafaev
Timur Mustafaev

Reputation: 4929

Disk space for downloaded files in ios app

My app downloads files. How much space I can use for downloaded files? App size is 3-4 mbytes. I save files to documents folder.

Upvotes: 1

Views: 867

Answers (1)

Danra
Danra

Reputation: 9906

There is no capacity limit except the available storage (except for the fact that the app may see a bit less storage then what is actually available on the device - some may be saved for the OS).

To get the free storage available on the device (as your app is concerned):

NSString* docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:docsDir error:NULL];
unsigned long long freeSpaceInBytes = [[fileAttributes objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
NSLog(@"Memory Capacity of %llu MiB.", ((freeSpaceInBytes/1024ll)/1024ll));

Upvotes: 6

Related Questions