• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get Machine Type string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get Machine Type string


  • Subject: Re: Get Machine Type string
  • From: Shaun Wexler <email@hidden>
  • Date: Fri, 28 Jul 2006 13:58:04 -0700

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


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Re: Get Machine Type string
      • From: "Shawn Erickson" <email@hidden>
    • Re: Get Machine Type string
      • From: Shaun Wexler <email@hidden>
References: 
 >Get Machine Type string (From: "matt jaffa" <email@hidden>)

  • Prev by Date: Re: Checking file modification dates in NSDocument
  • Next by Date: Re: How to make KVO setup persistent?
  • Previous by thread: Re: Get Machine Type string
  • Next by thread: Re: Get Machine Type string
  • Index(es):
    • Date
    • Thread