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

标签 iphone ios xcode cocoa-touch

我执行此任务是为了读取一些设备信息,例如设备名称、类型、磁盘空间和 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/

相关文章:

ios - 更新 RecyclerView 适配器中 Cardview 内的图表

ios - Storyboard UI 元素未显示在编辑器中

iphone - CoreGraphics 中的透明背景

ios - FirebaseAutomaticScreenReportingEnabled 甚至禁用了我的电话

ios - '无法在包 : 'NSBundle | Error while switching to Xcode 4 and creating an iPad version of an app 中加载 NIB

ios - 如何知道第三方编写的代码是否在发布时运行

iphone - 当用户在 iOS 5 上锁定屏幕时 applicationMusicPlayer 停止

ios - 为不同的iphone设置图像并调试

ios - 使用 WhatsApp URL Scheme 发送我的 App URL Scheme

iphone - 使用 webview 通过 safari 打开链接的问题