一,代码。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSFileManager *fm = [NSFileManager defaultManager];
NSDictionary *fattributes = [fm attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
NSLog(@"容量%lldG",[[fattributes objectForKey:NSFileSystemSize] longLongValue]/1000000000);
NSLog(@"可用%lldG",[[fattributes objectForKey:NSFileSystemFreeSize] longLongValue]/1000000000);
}
二,输出。
2015-10-19 13:37:44.929 获得当前硬盘空间[5256:118910] 容量249G
2015-10-19 13:37:44.929 获得当前硬盘空间[5256:118910] 可用113G