Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/sysctl.h>
- + (NSString*)hardwareString
- {
- int name[] = {CTL_HW,HW_MACHINE};
- size_t size = 100;
- sysctl(name, 2, NULL, &size, NULL, 0); // getting size of answer
- char *hw_machine = malloc(size);
- sysctl(name, 2, hw_machine, &size, NULL, 0);
- NSString *hardware = [NSString stringWithUTF8String:hw_machine];
- free(hw_machine);
- return hardware;
- }
- + (BOOL)isSimulator
- {
- BOOL simulator = NO; // default NO for Mac OSX
- #if TARGET_OS_SIMULATOR || TARGET_OS_IOS || TARGET_OS_TV
- NSString *hardware = [self hardwareString];
- simulator = [hardware isEqualToString:@"x86_64"];
- #endif
- return simulator;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement