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
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 mails | Author | Date |
|---|---|---|
| matt jaffa | Jul 28, 16:51 | |
| Shawn Erickson | Jul 28, 16:52 | |
| Shawn Erickson | Jul 28, 16:58 | |
| matt jaffa | Jul 28, 17:53 | |
| Michael Watson | Jul 28, 18:17 | |
| Chris Vetter | Jul 28, 18:27 | |
| Shaun Wexler | Jul 28, 22:58 | |
| Shaun Wexler | Jul 28, 23:06 | |
| Shawn Erickson | Jul 28, 23:18 | |
| Shaun Wexler | Jul 29, 23:14 |






Cocoa mail archive

