iOS 获取手机剩余空间和总空间
2017-12-21 本文已影响50人
孤胆走天涯
-
(NSString *)getDivceSize{
NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
NSNumber *freeber = [fattributes objectForKey:NSFileSystemFreeSize];
NSNumber *maxber = [fattributes objectForKey:NSFileSystemSize];long long freespace = [freeber longLongValue];
long long maxspace = [maxber longLongValue];NSString * sizeStr = [NSString stringWithFormat:@"剩余空间%0.1fG / 共%0.1fG",(double)freespace/1024/1024/1024,(double)maxspace/1024/1024/1024];
return sizeStr;
}