gpt4 book ai didi

iphone - 如何确定 iphone/ipad/ipod/appletv 是旧的、更新的还是与同一系列的其他设备相同?

转载 作者:行者123 更新时间:2023-11-28 22:41:33 25 4
gpt4 key购买 nike

如何比较不同的平台?

例子:我想知道当前设备是否比 iPhone 4S 更旧。

最佳答案

将这些方法添加到某个类(例如 YourClass):

+(NSString*)deviceVersion{
// get hardware device version string
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
/* possible values:
@"i386" (or similar) on the simulator //
@"iPod1,1" on iPod Touch
@"iPod2,1" on iPod Touch Second Generation
@"iPod3,1" on iPod Touch Third Generation
@"iPod4,1" on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPad2,1" on iPad 2
@"iPad3,1" on iPad 3 (aka new iPad)
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S
@"iPhone5,1" on iPhone 5
@"iPhone5,2" on iPhone 5
...future version...? */
}

+(NSNumber *)getVersionForDevice:(NSString*)deviceToCheck{
NSNumber* versionNumber = nil;
if (deviceToCheck && ![deviceToCheck isEqualToString:@""]) {
NSString* deviceMachine = [Utils deviceVersion];
NSString* deviceVersion = nil;
if ([deviceMachine hasPrefix:deviceToCheck]) {
deviceVersion = [deviceMachine stringByReplacingOccurrencesOfString:deviceToCheck withString:@""];
deviceVersion = [deviceVersion stringByReplacingOccurrencesOfString:@"," withString:@"."];
float floatVersion = [deviceVersion floatValue];
versionNumber = [NSNumber numberWithFloat:floatVersion];
}
}
return versionNumber;
}


+(BOOL)isSimulator{
NSString* deviceMachine = [Utils deviceVersion];
// NSLog(@"Utils deviceMachine: %@", deviceMachine);
if (![deviceMachine hasPrefix:@"iPhone"] && ![deviceMachine hasPrefix:@"iPod"] && ![deviceMachine hasPrefix:@"iPad"]) {
return 1;
}
return 0;
}

然后,如果在 iPhone 上并且想测试版本:

float iPhoneVersion = [[YourClass getVersionForDevice:@"iPhone"] floatValue];

并为 iPad...iPod...做类似的调用

关于iphone - 如何确定 iphone/ipad/ipod/appletv 是旧的、更新的还是与同一系列的其他设备相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14398736/

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