终端拿到关于本机里的信息

2019-10-21  本文已影响0人  皮蛋豆腐酱油
system_profiler SPHardwareDataType
system_profiler 的其他类型通过system_profiler -listDataTypes可知

Available Datatypes:
SPParallelATADataType
SPUniversalAccessDataType
SPSecureElementDataType
SPApplicationsDataType
SPAudioDataType
SPBluetoothDataType
SPCameraDataType
SPCardReaderDataType
SPComponentDataType
SPiBridgeDataType
SPDeveloperToolsDataType
SPDiagnosticsDataType
SPDisabledSoftwareDataType
SPDiscBurningDataType
SPEthernetDataType
SPExtensionsDataType
SPFibreChannelDataType
SPFireWireDataType
SPFirewallDataType
SPFontsDataType
SPFrameworksDataType
SPDisplaysDataType  //图形卡/显示器
SPHardwareDataType
SPHardwareRAIDDataType
SPInstallHistoryDataType
SPLegacySoftwareDataType
SPNetworkLocationDataType
SPLogsDataType
SPManagedClientDataType
SPMemoryDataType  //内存
SPNVMeDataType
SPNetworkDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrefPaneDataType
SPPrintersSoftwareDataType
SPPrintersDataType
SPConfigurationProfileDataType
SPRawCameraDataType
SPSASDataType
SPSerialATADataType
SPSPIDataType
SPSmartCardsDataType
SPSoftwareDataType
SPStartupItemDataType
SPStorageDataType
SPSyncServicesDataType
SPThunderboltDataType
SPUSBDataType
SPNetworkVolumeDataType
SPWWANDataType
SPAirPortDataType

参考:https://blog.csdn.net/LIHUINIHAO/article/details/54772722

- (NSString *)getProduceDate {
    NSString *modelIdentifier = @"";
    NSString *cmd1 = @"system_profiler SPHardwareDataType | grep 'Model Identifier'";
    modelIdentifier = [IProcessMgr cmdShellScript:cmd1];
    modelIdentifier = [modelIdentifier substringFromIndex:24];
    modelIdentifier = [modelIdentifier stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    
    NSString *date = @"";
    NSString *path = @"/System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/English.lproj/SIMachineAttributes.plist";
    NSDictionary *SIMachineAttributesDic = [[NSDictionary alloc] initWithContentsOfFile:path];
    for (NSString *s in SIMachineAttributesDic.allKeys) {
        if ([s isEqualToString:modelIdentifier]) {
            NSDictionary *infoDic = [[SIMachineAttributesDic objectForKey:s] objectForKey:@"_LOCALIZABLE_"];
            date = [infoDic objectForKey:@"description"];
            break;
        }
    }
    NSLog(@"date = %@",date);
    
    
    
    return date;
}
上一篇下一篇

猜你喜欢

热点阅读