Re: Identifying a specific Mac model
Re: Identifying a specific Mac model
- Subject: Re: Identifying a specific Mac model
- From: Marek Hrušovský <email@hidden>
- Date: Mon, 14 Sep 2015 11:21:11 +0200
To get color/icon Manually map model identifier to icon name and then use
e.g
[[NSWorkspace sharedWorkspace] iconForFileType:@"com.apple.macbookair"];
http://stackoverflow.com/questions/32370037/is-there-a-way-of-getting-a-macs-icon-given-its-model-number/32373977#32373977
On Mon, Sep 14, 2015 at 11:17 AM, Marek Hrušovský <email@hidden>
wrote:
> NSPipe *outputPipe = [NSPipe pipe];NSTask *task = [[NSTask alloc] init];[task setLaunchPath:@"/usr/sbin/system_profiler"];[task setArguments:@[@"SPHardwareDataType"]];[task setStandardOutput:outputPipe];[task launch];[task waitUntilExit];NSData *outputData = [[outputPipe fileHandleForReading] readDataToEndOfFile];NSString *hardware = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
>
>
> Mareks-MacBook-Pro:~ xhruso00$ /usr/sbin/system_profiler SPHardwareDataType
>
> Hardware:
>
>
> Hardware Overview:
>
>
> Model Name: MacBook Pro
>
> Model Identifier: MacBookPro6,2
>
> Processor Name: Intel Core i5
>
> Processor Speed: 2,4 GHz
>
> Number of Processors: 1
>
> Total Number of Cores: 2
>
> L2 Cache (per Core): 256 KB
>
> L3 Cache: 3 MB
>
> Memory: 8 GB
>
> Processor Interconnect Speed: 4,8 GT/s
>
> Boot ROM Version: MBP61.0057.B10
>
> SMC Version (system): 1.58f17
>
> Serial Number (system): hidden
>
> Hardware UUID: hidden
>
> Sudden Motion Sensor:
>
> State: Enabled
>
> On Mon, Sep 14, 2015 at 10:17 AM, Robert Tillyard <email@hidden>
> wrote:
>
>> Hello, John,
>>
>> I use this to get the model number:
>>
>>
>> + (NSString *)computerModel
>> {
>> char modelBuffer[256];
>> size_t sz = sizeof(modelBuffer);
>>
>> if (0 == sysctlbyname("hw.model", modelBuffer, &sz, NULL, 0)) {
>> modelBuffer[sizeof(modelBuffer) - 1] = 0;
>> return [NSString stringWithCString:modelBuffer
>> encoding:[NSString defaultCStringEncoding]];
>> }
>>
>> return nil;
>> }
>>
>> Regards, Rob.
>>
>>
>> > On 14 Sep 2015, at 01:09, John Daniel <email@hidden>
>> wrote:
>> >
>> > Hello,
>> > Does anyone know of an API or utility that will identify specific Mac
>> models? The “Model Identifier” like “MacBook8,1” is not sufficient to
>> uniquely describe a model. MacBook8,1 covers all colours of the new
>> MacBook. I am trying to differentiate the silver, from the space grey, from
>> the gold.
>> >
>> > My app has an animation where it cycles through various Macs like a
>> slot machine, finally landing on the user’s specific machine. I used to
>> just look at the “Model Identifier”. I could pretty easily identify the
>> matching machine image from
>> /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources.
>> >
>> > However, the images for the new retina MacBook are in a different
>> location. I found where they live in an apparently randomly-named
>> framework, but I still can’t connect a specific image with the user’s
>> specific machine. There is a private API for the UIDevice class in iOS that
>> provides similar information. Is there anything like this for the Mac?
>> >
>> > Thanks,
>> >
>> > John Daniel
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>>
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden