This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSString *)getOSBuildNumber { | |
int mib[2] = {CTL_KERN, KERN_OSVERSION}; | |
u_int namelen = sizeof(mib) / sizeof(mib[0]); | |
size_t bufferSize = 0; | |
NSString *osBuildVersion = nil; | |
// Get the size for the buffer | |
sysctl(mib, namelen, NULL, &bufferSize, NULL, 0); | |
u_char buildBuffer[bufferSize]; | |
int result = sysctl(mib, namelen, buildBuffer, &bufferSize, NULL, 0); | |
if (result >= 0) { | |
osBuildVersion = [[NSString alloc] initWithBytes:buildBuffer length:bufferSize encoding:NSUTF8StringEncoding]; | |
} | |
NSCharacterSet *charsToRemove = [[NSCharacterSet alphanumericCharacterSet] invertedSet]; | |
return [[osBuildVersion componentsSeparatedByCharactersInSet:charsToRemove] componentsJoinedByString:@""]; | |
} |