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

来源:互联网 发布:js正方形3d立体旋转 编辑:程序博客网 时间:2024/05/22 03:28

//联系人:石虎 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 或者是码云上;


谢谢!!!


阅读全文
0 0
原创粉丝点击