Show available Physical memory on Device (iphone/ipad)
Anybody knows how to 开发者_开发问答find out how much physical memory is used and available now?
I need to show in my iPad application smth like this:
Free memory is 14.1 / 16Gb You application's files takes 1412 Mb
I will store big files in my app and should know about used memory - to delete some files and write new
smth like physical memory managment
It sounds like by "memory" you mean filesystem storage. Something like this should get you what you want:
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSDictionary *info = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error:NULL];
NSUInteger totalSpace = [[info objectForKey:NSFileSystemSize] unsignedIntegerValue];
NSUInteger freeSpace = [[info objectForKey:NSFileSystemFreeSize] unsignedIntegerValue];
精彩评论