开发者

Disk space for downloaded files in ios app

开发者 https://www.devze.com 2023-04-07 21:12 出处:网络
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.There is no capacity limit except the available storage (

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.


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));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号