计算磁盘大小

+ (float)getTotalDiskSpaceInBytes {
	float totalSpace = 0.0f;
	NSError *error = nil;
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
	
	if (dictionary) {
		NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
		totalSpace = [fileSystemSizeInBytes floatValue];
	} else {
		NSLog(@"Error Obtaining File System Info: Domain = %@, Code = %@", [error domain], [error code]);
	}
	
	return totalSpace;
}
 

你可能感兴趣的:(ios,iPhone,磁盘大小)