iOS(二) 获取当前 App 设备相关信息

远程获取:

NSString * url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",AppIDs];//替换为自己App的ID


NSURL *url = [NSURL URLWithString:@"此处填写当前应用在 App Store 中的链接地址"];
NSError *error;
NSString *jsonResStr = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
NSData *data = [jsonResStr dataUsingEncoding:NSUTF8StringEncoding];
id jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
NSArray *arr = jsonData[@"results"];
for (NSDictionary *dict in arr) {
    NSLog(@"App Store Data: %@", dict);
    NSString *versionStr = [dict objectForKey:@"version"];

}

2.全局文件:

#pragma mark - 获取相关资料
 
/** 获取bundle Id信息*/
#define kGetBundleId        [[NSBundle mainBundle] bundleIdentifier]
/** 获取 App 名称*/
#define kGetAppDisplayName  [[[NSBundle mainBundle] bundleIdentifier] objectForKey:@"CFBundleDisplayName"]
/** APP版本号 Version*/
#define kAppVersion         [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
/** APP包版本号 BundleVersion*/
#define kAppBundle          [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
/** 获取设备名称:手机别名(即:用户定义的名称)*/
#define kGetDeviceName      [[UIDevice currentDevice] name]
/** 获取设备类型*/
#define kGetDeviceModel     [[UIDevice currentDevice] model]
/** 获取设备 UUID*/
#define kGetDeviceUUID      [[UIDevice currentDevice].identifierForVendor UUIDString]
/** 获取系统名称*/
#define kSystemName         [[UIDevice currentDevice] systemName]
/** 系统版本号*/
#define kSystemVersion      [[UIDevice currentDevice] systemVersion]
/** 获取地方型号(即:国际化区域名称)*/
#define kLocalPhoneModel    [[UIDevice currentDevice] localizedModel]
/** 获取当前语言*/
#define kCurrentLanguage    ([[NSLocale preferredLanguages] objectAtIndex:0])
/** 获取沙盒 Document 路径*/
#define kDocumentPath       [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]
/** 获取沙盒 Library 路径*/
#define kLibraryPath        [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject]
/** 获取沙盒 temp 路径(注:iPhone 重启会清空)*/
#define kTempPath           NSTemporaryDirectory()
/** 获取沙盒 Cache 路径*/
#define kCachePath          [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]
/** 获取程序包中程序路径*/
#define kResource(f, t)     [[NSBundle mainBundle] pathForResource:(f) ofType:(t)];
/** 获取系统时间戳*/
#define getCurrentTime      [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]
/** 屏幕分辨率*/
#define SCREEN_RESOLUTION   (SCREEN_WIDTH * SCREEN_HEIGHT * ([UIScreen mainScreen].scale))

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

我先来一碗

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

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

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

打赏作者

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

抵扣说明:

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

余额充值