添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
"CFFIXED_USER_HOME" = "/private/var/mobile/Containers/Data/Application/25EFAF50-01E9-4C28-995D-F7FD3156F848"; CLASSIC = 0; "DYLD_LIBRARY_PATH" = "/usr/lib/system/introspection"; HOME = "/private/var/mobile/Containers/Data/Application/25EFAF50-01E9-4C28-995D-F7FD3156F848"; LOGNAME = mobile; NSUnbufferedIO = YES; "OS_ACTIVITY_DT_MODE" = YES; PATH = "/usr/bin:/bin:/usr/sbin:/sbin"; SHELL = "/bin/sh"; TMPDIR = "/private/var/mobile/Containers/Data/Application/25EFAF50-01E9-4C28-995D-F7FD3156F848/tmp/"; USER = mobile; "XPC_FLAGS" = 0x0; "XPC_SERVICE_NAME" = "UIKitApplication:com.caad.GCD-OC[0x375e][67]"; "__CF_USER_TEXT_ENCODING" = "0x1F5:0:0";
命令行参数
processInfo.arguments;

获取进程开启的时候,传入的命令行参数信息,是一个参数数组,如下:

"/Users/caad/Library/Developer/CoreSimulator/Devices/B74675E4-26F5-499D-B801-7C7C1C16DCB3/data/Containers/Bundle/Application/68D5B197-2B4B-409D-A173-2B8F682DEE1F/GCD_OC.app/GCD_OC", "{name:\U715c,job:iOS Engineer}"
processInfo.processName;

进程名称默认与项目的名称相同,可以更改,如下:

NSLog(@"processName:%@",processInfo.processName);
// 我的项目名称是GCD_OC,所以打印结果是:GCD_OC
processInfo.processName = @"custom_process_name";
NSLog(@"processName:%@",processInfo.processName);
// 打印结果是:custom_process_name
processInfo.processIdentifier;
全球唯一码
processInfo.globallyUniqueString;

进程每启动一次,生成的globallyUniqueString都不同,

操作系统版本号
processInfo.operatingSystemVersionString;

获取运行当前进程的设备的操作系统的版本号字符串,打印结果如下:

Version 11.2 (Build 15C107)

另一种获取当前系统版本号,得到的结果时结构体,包含:主版本号,次版本号,补丁版本号

processInfo.operatingSystemVersion;

系统启动的时间

processInfo.systemUptime;

获取系统启动的时间,单位是秒。(我总感觉这个时间统计的不太准确)

获取iOS设备是否开启了低电量模式
processInfo.lowPowerModeEnabled;

得到的是一个布尔值的结果:YES:开启了低电量模式,NO:未开启低电量模式

    NSProcessInfo *processInfo = [NSProcessInfo processInfo];
    NSLog(@"environment:%@",processInfo.environment);
    NSLog(@"arguments:%@",processInfo.arguments);
    NSLog(@"hostName:%@",processInfo.hostName);
    processInfo.processName = @"custom_process_name";
    NSLog(@"processName:%@",processInfo.processName);
    NSLog(@"processIdentifier:%d",processInfo.processIdentifier);
    NSLog(@"globallyUniqueString:%@",processInfo.globallyUniqueString);
    NSLog(@"operatingSystemVersionString:%@",processInfo.operatingSystemVersionString);
    NSLog(@"operatingSystemVersion.majorVersion:%ld",processInfo.operatingSystemVersion.majorVersion);
    NSLog(@"operatingSystemVersion.minorVersion:%ld",processInfo.operatingSystemVersion.minorVersion);