Does Mac OS X have API that translates Apple's model identifiers (the kind found in plists and APIs, e.g., "MacBookPro5,1") to user-friendly marketing names of these 开发者_JS百科devices ("Unibody MacBook Pro Late 2008")?
I'm looking for more future-proof solution than simply hardcoding a list.
You could access the following property list to get the human friendly name.
/System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/English.lproj/SIMachineAttributes.plist
Try scraping this Wikipedia page: http://en.wikipedia.org/wiki/Timeline_of_Apple_Macintosh_models
Of course, this isn't guaranteed to continue to work, but it's a start.
One of the better options I've found was answered at https://apple.stackexchange.com/questions/98080/can-a-macs-model-year-be-determined-with-a-terminal-command.
In short, you can query Apple's servers for the marketing name of the computer using the last 4 characters of the hardware's serial number.
https://support-sp.apple.com/sp/product?cc=XXXX
For example
https://support-sp.apple.com/sp/product?cc=G8WL
There's no table built into the Apple libraries for that. Sorry.
精彩评论