1 -(void)usedSpaceAndfreeSpace{ 2 NSString* path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] ; 3 NSFileManager* fileManager = [[NSFileManager alloc ]init]; 4 NSDictionary *fileSysAttributes = [fileManager attributesOfFileSystemForPath:path error:nil]; 5 NSNumber *freeSpace = [fileSysAttributes objectForKey:NSFileSystemFreeSize]; 6 NSNumber *totalSpace = [fileSysAttributes objectForKey:NSFileSystemSize]; 7 spaceLabel.text = [NSString stringWithFormat:@"已占用%0.1fG/剩余%0.1fG",([totalSpace longLongValue] - [freeSpace longLongValue])/1024.0/1024.0/1024.0,[freeSpace longLongValue]/1024.0/1024.0/1024.0]; 8 }
转载于:https://www.cnblogs.com/lynn87/archive/2012/04/25/2469497.html