HTML5 专栏ios实用开发技巧

iOS 获取程序~项目app名称、版本号、build版本

2017-11-29  本文已影响127人  石虎132

//联系人:石虎QQ:1224614774昵称:嗡嘛呢叭咪哄

/**

1.图形显示

2.代码实现

3.下载 demo

*/

一、图形展示

图1:

图2:

二、代码实现

//

//  ViewController.m

//  自动增减算法

//

//  Created by 石虎 on 2017/9/29.

//  Copyright © 2017年 石虎. All rights reserved.

//

#import"ViewController.h"

@interface ViewController ()

@end

/** 获取APP名称 */

#define APP_NAME ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"])

/** 程序版本号 */

#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

/** 获取APP build版本 */

#define APP_BUILD ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"])

/** User-Agent */

#define APP_USER_AGENT [NSString stringWithFormat:@"石虎/%@ (%@;U;%@ %@;%@/%@)", \

APP_VERSION, DeviceModel, DeviceSystemName, DeviceVersion, DeviceLocal, DeviceLang]

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

NSLog(@"获取APP名称 === %@,程序版本号===,%@,获取APP build版本==,%@",APP_NAME,APP_VERSION,APP_BUILD);

}

@end

三、打印结果

打印:2017-10-0915:05:03.296自动增减算法[44032:2027891] 获取APP名称 === shihu ,程序版本号===,1.0.2,获取APP build版本==,12345

四、下载 demo 链接

请联系本人,代码会发布在 GitHub 或者是码云上;

谢谢!!!

上一篇 下一篇

猜你喜欢

热点阅读