gpt4 book ai didi

iphone - Cocoa touch——获取设备信息

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:05 28 4
gpt4 key购买 nike

我执行此任务是为了读取一些设备信息,例如设备名称、类型、磁盘空间和 iOS 版本。我有一些方法可以知道该设备是 iPad、iPhone 还是视网膜,但我对进一步了解该设备一无所知。

最佳答案

阅读 iOS 版本:

NSString* iOSVersion = [[UIDevice currentDevice] systemVersion];

阅读 iPad 型号:

BOOL isIPad2 = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
[UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]);
NSString* iPadModel = [[UIDevice currentDevice] model];
if (isIPad2)
iPadModel = @"iPad2";

读取空闲/总空间磁盘:

- (NSNumber *) totalDiskSpace
{
NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
return [fattributes objectForKey:NSFileSystemSize];
}

- (NSNumber *) freeDiskSpace
{
NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
return [fattributes objectForKey:NSFileSystemFreeSize];
}

关于iphone - Cocoa touch——获取设备信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8242469/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com