Skip to content

Instantly share code, notes, and snippets.

@roothybrid7
Created February 1, 2015 23:11
Show Gist options
  • Save roothybrid7/3a225b5056b6bf806777 to your computer and use it in GitHub Desktop.
Save roothybrid7/3a225b5056b6bf806777 to your computer and use it in GitHub Desktop.
デバイスが32bitなのか64bitなのかチェックする ref: http://qiita.com/roothybrid7/items/3cfeb2837cb468bcab13
if (sizeof(int *) == 4) {
// 32bit
} else if (sizeof(int *) == 8) {
// 64bit
}
// others
// UIDevice+Hardware.h
typedef NS_ENUM(NSUInteger, DeviceArchitecture) {
DeviceArchitectureUnknown,
DeviceArchitecture32Bit,
DeviceArchitecture64Bit,
};
@interface UIDevice (Hardware)
- (DeviceArchitecture)cpuArchitecture;
@end
// UIDevice+Hardware.m
#import "UIDevice+Hardware.h"
@implementation UIDevice (Hardware)
- (DeviceArchitecture)cpuArchitecture {
if (sizeof(int *) == 4) {
return DeviceArhictecture32Bit;
} else if (sizeof(int *) == 8) {
return DeviceArchitecture64Bit;
}
return DeviceArchitectureUnknown;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment