Skip navigation.
 
mlRe: Get Machine Type string
FROM : Shaun Wexler
DATE : Fri Jul 28 22:58:04 2006

On Jul 28, 2006, at 7:51 AM, matt jaffa wrote:

> Is there any cocoa api or other api that can get what type of machine
> it is. i.e. MacBook Pro, Powerbook, etc. I can easily get the machine
> model like MacBookPro1,1.


IOKit is your friend.  Use it.  ;)

+ (NSString *)computerModel
{
    static NSString *computerModel = nil;

    if (!computerModel) {
        io_service_t pexpdev;
        if ((pexpdev = IOServiceGetMatchingService
(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"))))
        {
            NSData *data;
            if ((data = (id)IORegistryEntryCreateCFProperty(pexpdev, 
CFSTR("model"), kCFAllocatorDefault, 0))) {
                computerModel = [[NSString allocWithZone:NULL] 
initWithCString:[data bytes] encoding:NSASCIIStringEncoding];
                [data release];
            }
        }
    }

    return computerModel;
}

--
Shaun Wexler
MacFOH
http://www.macfoh.com

"Things should be described as simply as possible, but no simpler." - 
Albert Einstein

Related mailsAuthorDate
mlGet Machine Type string matt jaffa Jul 28, 16:51
mlRe: Get Machine Type string Shawn Erickson Jul 28, 16:52
mlRe: Get Machine Type string Shawn Erickson Jul 28, 16:58
mlRe: Get Machine Type string matt jaffa Jul 28, 17:53
mlRe: Get Machine Type string Michael Watson Jul 28, 18:17
mlRe: Get Machine Type string Chris Vetter Jul 28, 18:27
mlRe: Get Machine Type string Shaun Wexler Jul 28, 22:58
mlRe: Get Machine Type string Shaun Wexler Jul 28, 23:06
mlRe: Re: Get Machine Type string Shawn Erickson Jul 28, 23:18
mlRe: Get Machine Type string Shaun Wexler Jul 29, 23:14