参考了很多帖子,最后根据项目需求,修正了一些错误,总结了一个相对更全面一些的公用模块:
#import <UIKit/UIKit.h>
@interface UIDevice (Info)
+ (NSString *) device; //设备类型(x86_64 iPod5,1)
+ (NSString *) deviceModel; //设备模式(iPad iPod iPhone)
+ (NSString *) osVersion; //系统版本
+ (NSString *) os; //平台
+ (NSString *) carrier; //运营商
+ (NSString *) resolution; //分辨率
+ (NSString *) locale; //地域
+ (NSString *) appVersion; //程序版本
+ (NSNumber *) timestamp; //unix timestamp
+ (NSString *) cpuType; //cpu型号
+ (NSString *) cpuFrequency; //cpu频率
+ (NSUInteger) cpuCount; //cpu核数
+ (NSArray *) cpuUsage; //cpu利用率
+ (NSUInteger) totalMemoryBytes; //获取手机内存总量,返回的是字节数
+ (NSUInteger) freeMemoryBytes; //获取手机可用内存,返回的是字节数
+ (long long) freeDiskSpaceBytes; //获取手机硬盘空闲空间,返回的是字节数
+ (long long) totalDiskSpaceBytes; //获取手机硬盘总空间,返回的是字节数
+ (BOOL ) isJailBreak; //是否越狱
+ (BOOL ) bluetoothCheck; //是否支持蓝牙
@end
#import "UIDevice+Info.h"
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
#import <mach/mach.h>
#import <mach/mach_host.h>
#import <sys/types.h>
#import <sys/param.h>
#import <sys/mount.h>
#import <mach/processor_info.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <net/if.h>
#include <net/if_dl.h>
#define IFPGA_NAMESTRING @"iFPGA"
#define IPHONE_1G_NAMESTRING @"iPhone 1G"
#define IPHONE_3G_NAMESTRING @"iPhone 3G"
#define IPHONE_3GS_NAMESTRING @"iPhone 3GS"
#define IPHONE_4_NAMESTRING @"iPhone 4"
#define IPHONE_4S_NAMESTRING @"iPhone 4S"
#define IPHONE_5_NAMESTRING @"iPhone 5"
#define IPHONE_UNKNOWN_NAMESTRING @"Unknown iPhone"
#define IPOD_1G_NAMESTRING @"iPod touch 1G"
#define IPOD_2G_NAMESTRING @"iPod touch 2G"
#define IPOD_3G_NAMESTRING @"iPod touch 3G"
#define IPOD_4G_NAMESTRING @"iPod touch 4G"
#define IPOD_UNKNOWN_NAMESTRING @"Unknown iPod"
#define IPAD_1G_NAMESTRING @"iPad 1G"
#define IPAD_2G_NAMESTRING @"iPad 2G"
#define IPAD_3G_NAMESTRING @"iPad 3G"
#define IPAD_4G_NAMESTRING @"iPad 4G"
#define IPAD_UNKNOWN_NAMESTRING @"Unknown iPad"
#define APPLETV_2G_NAMESTRING @"Apple TV 2G"
#define APPLETV_3G_NAMESTRING @"Apple TV 3G"
#define APPLETV_4G_NAMESTRING @"Apple TV 4G"
#define APPLETV_UNKNOWN_NAMESTRING @"Unknown Apple TV"
#define IOS_FAMILY_UNKNOWN_DEVICE @"Unknown iOS device"
#define SIMULATOR_NAMESTRING @"iPhone Simulator"
#define SIMULATOR_IPHONE_NAMESTRING @"iPhone Simulator"
#define SIMULATOR_IPAD_NAMESTRING @"iPad Simulator"
#define SIMULATOR_APPLETV_NAMESTRING @"Apple TV Simulator" // :)
//iPhone 3G 以后各代的CPU型号和频率
#define IPHONE_3G_CPUTYPE @"ARM11"
#define