#pragma mark 检查设备剩余内存
-(void)usedSpaceAndfreeSpace
{
NSFileManager* fileManager = [[NSFileManager alloc ]init];
NSDictionary *fileSysAttributes = [fileManager attributesOfFileSystemForPath:DocumentsPath error:nil];
NSNumber *freeSpace = [fileSysAttributes objectForKey:NSFileSystemFreeSize];
NSNumber *totalSpace = [fileSysAttributes objectForKey:NSFileSystemSize];
NSString * str= [NSString stringWithFormat:@"已占用%0.1fG/剩余%0.1fG",([totalSpace longLongValue] - [freeSpace longLongValue])/1024.0/1024.0/1024.0,[freeSpace longLongValue]/1024.0/1024.0/1024.0];
NSLog(@"--------%@",str);
}
--------已占用359.1G/剩余571.6G
时间: 2024-10-11 12:23:03