Ste*_*ynx 2 iphone xcode cocoa-touch ios
我执行此任务来读取一些设备信息,如设备名称,类型,磁盘空间和iOS版本.我有一些方法可以知道这个设备是iPad,iPhone还是视网膜,但是我对进一步了解该设备毫无头绪.
阅读iOS版本:
NSString* iOSVersion = [[UIDevice currentDevice] systemVersion];
Run Code Online (Sandbox Code Playgroud)
阅读iPad模型:
BOOL isIPad2 = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
[UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]);
NSString* iPadModel = [[UIDevice currentDevice] model];
if (isIPad2)
iPadModel = @"iPad2";
Run Code Online (Sandbox Code Playgroud)
读取空闲/总空间磁盘:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3030 次 |
| 最近记录: |