iOS开发~设备信息

这篇博客汇总了在iOS开发中获取设备信息的方法,包括但不限于设备型号、系统版本、UUID等关键数据,经过实践验证,适用于各种项目需求。
摘要由CSDN通过智能技术生成

参考了很多帖子,最后根据项目需求,修正了一些错误,总结了一个相对更全面一些的公用模块:


#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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zfpp25_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值