Re: G4 vs G3
Re: G4 vs G3
- Subject: Re: G4 vs G3
- From: "Clark S. Cox III" <email@hidden>
- Date: Wed, 11 Jun 2003 09:02:09 -0400
On Wednesday, Jun 11, 2003, at 06:02 US/Eastern, Rolf wrote:
Hi,
Try the following:
+(NSString *)processor {
SInt32 gestaltReturnValue;
NSString * result = @"";
if (!Gestalt(gestaltNativeCPUtype, &gestaltReturnValue)) {
switch (gestaltReturnValue) {
case gestaltCPU601 :
case gestaltCPU603 :
case gestaltCPU604 :
case gestaltCPU603e :
case gestaltCPU603ev :
case gestaltCPU750 :
case gestaltCPU604e :
case gestaltCPU604ev : { result = @"G3"; break; }
case gestaltCPUG4 :
case gestaltCPUG47450 : { result = @"G4"; break; }
default: {
if (gestaltReturnValue > gestaltCPUG47450) {
result = @"G4 or better";
} else {
result = [NSString stringWithFormat:@"Unknown"];
}
}
}
} else { // Failed
}
return result;
}
A problem with that, the 601 through 604 are *not* G3's, but your code
incorrectly identifies them as such. Also, your call to
stringWithFormat: is pointless (you just pass it a constant string
anyway). I would probably code it like so:
+(NSString *)processor
{
SInt32 gestaltReturnValue;
NSAssert(Gestalt(gestaltNativeCPUtype, &gestaltReturnValue),
@"Gestalt failed");
if (gestaltReturnValue > gestaltCPUG47450)
{
return @"G4 or better";
}
else switch (gestaltReturnValue)
{
case gestaltCPU601: return @"601";
case gestaltCPU603:
case gestaltCPU603e:
case gestaltCPU603ev: return @"603";
case gestaltCPU604:
case gestaltCPU604e:
case gestaltCPU604ev: return @"604";
case gestaltCPU750: return @"G3";
case gestaltCPUG4:
case gestaltCPUG47450: return @"G4";
}
return @"Unknown";
}
--
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.