首页 > 代码库 > 判断设备容量

判断设备容量

- (float)getTotalDiskSpace

{

float totalSpace;

NSError * error;

NSDictionary * infoDic = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[self getHomeDirectory] error: &error];

if (infoDic) {

NSNumber * fileSystemSizeInBytes = [infoDic objectForKey: NSFileSystemSize];

totalSpace = [fileSystemSizeInBytes floatValue]/1024.0f/1024.0f/1024.0f;

return totalSpace;

} else {

NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);

return 0;

}

- (NSString *)getHomeDirectory

{

NSString * homePath = NSHomeDirectory();

return homePath;

}

判断设备容量