Skip to content

Commit

Permalink
Correctly Parse 2-digit MajorVersion
Browse files Browse the repository at this point in the history
Embaressing bug in 1.0.0 that should close EndlessFields problem in #2
  • Loading branch information
tomrittervg committed Oct 29, 2014
1 parent 6634809 commit 6f79466
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions You'll Never Take Me Alive!/LaptopSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ +(Boolean) canStandby
NSString* output = [CommandRunner runTaskGetOutput:@"sysctl hw.model"];

NSString* model;
NSInteger i;
NSInteger majorVersion;
NSInteger minorVersion;
Boolean isRetina;
Expand All @@ -48,16 +49,25 @@ +(Boolean) canStandby
return false;
}

//Reuse model variable
//We're using the model variable as a temp here
model = [split objectAtIndex:1];
//Grab the minor version after the comma
minorVersion = [model integerValue];

//Now make model the value left of the comma
model = [split objectAtIndex:0];
model = [model substringFromIndex:[model length]-1];
//Find the first non-digit from the back
i =[model length]-1;
while([[NSCharacterSet decimalDigitCharacterSet] characterIsMember:[model characterAtIndex:i]])
i--;
//Put that into model temprarily
model = [model substringFromIndex:i+1];
//And convert it to int
majorVersion = [model integerValue];

//Now start again and assign the model correctly
model = [split objectAtIndex:0];
model = [model substringToIndex:[model length]-1];
model = [model substringToIndex:i+1];

isRetina = [[NSScreen mainScreen] backingScaleFactor] == 2.0f;

Expand Down

0 comments on commit 6f79466

Please sign in to comment.