Friday, August 12, 2011

How to find the hardware version in iOS


+ (NSString *)getSysInfoByName:(char *)typeSpecifier {

size_t size;

sysctlbyname(typeSpecifier, NULL, &size, NULL, 0);

char *answer = malloc(size);

sysctlbyname(typeSpecifier, answer, &size, NULL, 0);

NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];

free(answer);

return results;

}


// to get the hardware version, we need to pass the argument hw.machine


[ClassName getSysInfoByName:"hw.machine"];


//getSysInfoByName is class method so we need to call by class name


1 comment:

rxbass said...

great tuts

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...