NSProcessInfo *processInfo = [NSProcessInfo processInfo];
//获取当前进程
NSLog(@"processInfo === %@", [NSProcessInfo processInfo]);
//当前进程的环境,例如输出log的设备等
NSLog(@"environment === %@", processInfo.environment);
//执行进程的电脑的主机名(反正我在手机上输出为空)
NSLog(@"hostName === %@", processInfo.hostName);
//进程名字(你的项目名字)
NSLog(@"processName === %@", processInfo.processName);
//进程的标示符,通常叫做进程ID,每次你重新运行项目这个值都会增加,加的数目看你开了几条进程,并且这个值会一直增加,除非你重启电脑,进程ID清0。
NSLog(@"processIdentifier === %d", processInfo.processIdentifier);
//每次运行都会生成一个不确定的标示符
NSLog(@"globallyUniqueString === %@", processInfo.globallyUniqueString);
//操作系统的版本号以及build号
NSLog(@"operatingSystemVersionString === %@", processInfo.operatingSystemVersionString);
//操作系统的版本号,大版本号.小版本号.小版本补丁号
NSLog(@"operatingSystemVersion === %ld\n%ld\n%ld", (long)processInfo.operatingSystemVersion.majorVersion, (long)processInfo.operatingSystemVersion.minorVersion, (long)processInfo.operatingSystemVersion.patchVersion);
//当前项目进程数量
NSLog(@"processorCount === %lu", (unsigned long)processInfo.processorCount);
//当前项目活跃进程数量
NSLog(@"activeProcessorCount === %lu", (unsigned long)processInfo.activeProcessorCount);
//设备的CPU物理内存,byte单位
NSLog(@"activeProcessorCount === %lu", (unsigned long)processInfo.physicalMemory);
//判断当前进程执行的系统版本是否低于所指定的版本
NSLog(@"isOperatingSystemAtLeastVersion: === %d", [processInfo isOperatingSystemAtLeastVersion:processInfo.operatingSystemVersion]);
//上次设备重启到现在的秒数
NSLog(@"systemUptime === %f", processInfo.systemUptime);
//- (id <NSObject>)beginActivityWithOptions:(NSActivityOptions)options reason:(NSString *)reason这个函数使某个进程变成某种状态,以及变成这种状态的理由,需要与- (void)endActivity:(id <NSObject>)activity结合使用。activity这个属性是用于显示结果的。
//- (void)performActivityWithOptions:(NSActivityOptions)options reason:(NSString *)reason usingBlock:(void (^)(void))block使某个进程变成某种状态,以及变成这种状态的理由,状态结束后会在block中回调
//- (void)performExpiringActivityWithReason:(NSString *)reason usingBlock:(void(^)(BOOL expired))block使某个进程活跃结束
//检索当前进程对系统是否设置为低功耗模式,这个属性值总为NO
NSLog(@"%d", processInfo.isLowPowerModeEnabled);
//FOUNDATION_EXTERN NSNotificationName const NSProcessInfoPowerStateDidChangeNotification进程功耗状态的变化
/**********************只能在MAC OS上使用************************/
//- (void)disableSuddenTermination禁止应用突然被干掉;
//- (void)enableSuddenTermination允许应用突然被干掉
//- (void)disableAutomaticTermination:(NSString *)reason禁止应用突然被干掉的理由
//- (void)enableAutomaticTermination:(NSString *)reason允许应用突然被干掉的理由
//automaticTerminationSupportEnabled是否支持自动终止,这玩意对上面几个方法没有影响,不想要在plist设置它,应该在applicationDidFinishLaunching:前设置这个属性
//@property (readonly, copy) NSString *userName返回进程所属电脑当前登陆用户的用户名
//@property (readonly, copy) NSString *fullUserName返回进程所属电脑当前登陆用户的全程
//@property (readonly) NSProcessInfoThermalState thermalState返回进程当前的忙碌状态,是一个枚举类型
// FOUNDATION_EXTERN NSNotificationName const NSProcessInfoThermalStateDidChangeNotification进程热状态的变化的通知KEY