11:54 pm | by olifarago

For an app we were developing I found myself needing to know the model and the disk capacity of the device the app was running on.

I found plenty of resource for identifying the device. The two methods appear to revolve around either testing the device for feature combinations known to appear on certain devices or using the sysctlbyname function in the standard C library. For various reasons I opted for the latter more information on which can be found on this site: http://iphonedevelopertips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html

Next was trying to find the capacity.  I could find very little information on this but eventually settled on this which worked well for me.

NSDictionary *fsAttr = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
float diskSize = [[fsAttr objectForKey:NSFileSystemSize] doubleValue] / 1000000000;
NSLog(@"Disk Size: %0.0f",diskSize);

Leave a Reply

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin