获取本机号码及设备信息

来源:互联网 发布:excel表格怎么筛选数据 编辑:程序博客网 时间:2024/04/29 22:13

一、获取手机号码

步骤如下:
1
)导入CoreTelephony这个private framework
2
)在xxx.m中加入红字部分:

#import "xxx.h"

extern NSString *CTSettingCopyMyPhoneNumber();


@implementation
+(NSString *)myNumber{
        return CTSettingCopyMyPhoneNumber();        
}
@end

其实很多地方都写了标识extern NSString *CTSettingCopyMyPhoneNumber();之后就可以直接引用CTSettingCopyMyPhoneNumber() 

一开始发现总报错说无此方法,非常纳闷,结果是一个字母大小写的问题,汗颜.汗颜

 

CTSettingCopyMyPhoneNumber();  这个方法可以返回手机号码

获取设备信息

NSString *content=[[NSString alloc]

                       initWithFormat:

                       @"unique id: %@ \nlocalized model: %@ \nsystem version: %@ \nsystem name: %@ \nmodel: %@",

                       [[UIDevice currentDevice] uniqueIdentifier],

                       [[UIDevice currentDevice] localizedModel],

                       [[UIDevice currentDevice] systemVersion],

                       [[UIDevice currentDevice] systemName],

                       [[UIDevice currentDevice] model]];

    NSLog(@"%@",content);