有没有办法在Swift中获取设备型号名称(iPhone 4S,iPhone 5,iPhone 5S等)?
我知道有一个名为的属性,UIDevice.currentDevice().model但它只返回设备类型(iPod touch,iPhone,iPad,iPhone模拟器等).
我也知道可以使用这种方法在Objective-C中轻松完成:
#import <sys/utsname.h>
struct utsname systemInfo;
uname(&systemInfo);
NSString* deviceModel = [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
Run Code Online (Sandbox Code Playgroud)
但是我正在Swift中开发我的iPhone应用程序,所以有人可以用同样的方式帮助我在Swift中解决这个问题吗?
UI_USER_INTERFACE_IDIOM()在Swift中,iPhone和iPad之间有什么相同的功能?
我得到一个Use of unresolved identifier在斯威夫特编译时错误.