这个也是undocument api
NSString* phoneNumber = CTSettingCopyMyPhoneNumber();
2. 总磁盘大小:
NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];[fattributes objectForKey:NSFileSystemSize];
剩余空间:
[fattributes objectForKey:NSFileSystemFreeSize];
3. 内存大小:
size_t size = sizeof(int);
int results;
int mib[2] = {CTL_HW, HW_PHYSMEM};
sysctl(mib, 2, &results, &size, NULL, 0);
4.
NetworkStatus netstatus = [reachable currentReachabilityStatus];
switch (netstatus)
{
case NotReachable:
// 没有网络连接
reachableStatus = NSLocalizedString(@"No Network", "");
break;
case ReachableViaWWAN:
// 使用3G网络
reachableStatus = @"GPRS/3G";
break;
case ReachableViaWiFi:
// 使用WiFi网络
reachableStatus = @"WIFI";
break;
}
这个可知网络类型。
5.
cpu和总线频率:
int result;
mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
length = sizeof(result);
if (sysctl(mib, 2, &result, &length, NULL, 0) < 0)
{
perror("getting cpu frequency");
}
printf("CPU Frequency = %u hz\n", result);
int result2;
mib[0] = CTL_HW;
mib[1] = HW_BUS_FREQ;
length = sizeof(result2);
if (sysctl(mib, 2, &result2, &length, NULL, 0) < 0)
{
perror("getting bus frequency");
}
printf("Bus Frequency = %u hz\n", result);
5.
得到4种内存信息:mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
vm_statistics_data_t vmstat;
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count) != KERN_SUCCESS)
{
NSLog(@"Failed to get VM statistics.");
[_dic setObject:@"Failed to get VM statistics." forKey:KTTMemorySize_Wire];
}
else
{
float total = vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count;
float wired = vmstat.wire_count / total * 100;
float active = vmstat.active_count / total * 100;
float inactive = vmstat.inactive_count / total * 100;
float free = vmstat.free_count / total * 100;
// NSString *str = [NSString stringWithFormat:@"%d %d %d %d %.2f %.2f %.2f %.2f %.0f %.0f"
// , vmstat.wire_count, vmstat.active_count, vmstat.inactive_count, vmstat.free_count
// , wired, active, inactive, free
// , total, total * pageSize
// ];
}