You can get a DADiskRef, then get a CFDictionaryRef from the DADiskCopyDescription function. From that CFDictionaryRef (which is toll-free bridged to NSDictionary) you can then get any of the keys describing the disk. One such key is kDADiskDescriptionMediaSizeKey.
For more info, read the header:
You can find a complete list of properties in the DADisk.h header in the Disk Arbitration Framework, along with a description of the expected data types for the values of each key.
Quoted from the subsection "Obtaining a Description Dictionary" of the Manipulating Disks reference linked above.
Also look at the links to the framework function references. Each function has a link to a relevant Sample Code project. Look there, too.
The attributesOfFileSystemForPath:error: method returns the attributes of a file-system, not a hard drive. For example, it won't account for other partitions, such as the recovery or EFI partitions. Also, if the disk has multiple user-defined partitions, it won't account for any of those.
To illustrate the difference, copy & paste this command into a Terminal window:
Code:
diskutil list
The item labeled "0:" will be the disk as a whole, i.e. the "hard drive". Each partition will also appear, i.e. the "file-systems" on the disk.
The OP asked for "hard drive capacity", which I took to refer to the physical hard drive, not to partitions (file-systems) on the drive. I could be wrong, depending on what the OP actually intends to use the data for.