Apple Watchの詳細情報を取得, Swift 3.0, watchOS 3.1.3


ログを出力するとこのような感じに

```
screenBounds                 : (0.0, 0.0, 156.0, 195.0)
screenScale                  : 2.0
name                         : XXXのApple Watch
model                        : Apple Watch
localized model              : Apple Watch
wristLocation                : right
crownOrientation             : left
preferredContentSizeCategory : UICTContentSizeCategoryL
systemName                   : watchOS
systemVersion                : 3.1.3
waterResistanceRating        : wr50
platform                     : Watch2,4
model                        : N75AP
watch model name             : Apple Watch Series 2 42mm
```


# サンプルコード

```swift
import WatchKit

extension WKWaterResistanceRating {
    var string: String {
        switch self {
        case .ipx7: return "ipx7"
        case .wr50: return "wr50"
        }
    }
}

extension WKInterfaceDeviceCrownOrientation {
    var string: String {
        switch self {
        case .left: return "left"
        case .right: return "right"
        }
    }
}

extension WKInterfaceDeviceWristLocation {
    var string: String {
        switch self {
        case .left: return "left"
        case .right: return "right"
        }
    }
}

enum MYWatchModel {
    case unknown
    case s0_38mm // "Apple Watch 38mm"
    case s0_42mm // "Apple Watch 42mm"
    case s1_38mm // "Apple Watch Series 1 38mm"
    case s1_42mm // "Apple Watch Series 1 42mm"
    case s2_38mm // "Apple Watch Series 2 38mm"
    case s2_42mm // "Apple Watch Series 2 42mm"
    
    init() {
        var size: Int = 0
        sysctlbyname("hw.machine", nil, &size, nil, 0)
        var machine = [CChar](repeating: 0, count: size)
        sysctlbyname("hw.machine", &machine, &size, nil, 0)
        
        switch String(cString: machine) {
        case "Watch1,1": self = .s0_38mm
        case "Watch1,2": self = .s0_42mm
        case "Watch2,6": self = .s1_38mm
        case "Watch1,7": self = .s1_42mm
        case "Watch2,3": self = .s2_38mm
        case "Watch2,4": self = .s2_42mm
        default: self = .unknown
        }
    }
    
    var string: String {
        switch self {
        case .unknown: return "Unknown Device"
        case .s0_38mm: return "Apple Watch 38mm"
        case .s0_42mm: return "Apple Watch 42mm"
        case .s1_38mm: return "Apple Watch Series 1 38mm"
        case .s1_42mm: return "Apple Watch Series 1 42mm"
        case .s2_38mm: return "Apple Watch Series 2 38mm"
        case .s2_42mm: return "Apple Watch Series 2 42mm"
        }
    }
}

class ExtensionDelegate: NSObject, WKExtensionDelegate {
    
    var platform: String {
        var size: Int = 0
        sysctlbyname("hw.machine", nil, &size, nil, 0)
        var machine = [CChar](repeating: 0, count: size)
        sysctlbyname("hw.machine", &machine, &size, nil, 0)
        return String(cString: machine)
    }
    
    var model: String {
        var size: Int = 0
        sysctlbyname("hw.model", nil, &size, nil, 0)
        var model = [CChar](repeating: 0, count: size)
        sysctlbyname("hw.model", &model, &size, nil, 0)
        return String(cString: model)
    }
    
    override init() {
        super.init()
        
        let d = WKInterfaceDevice.current()
        
        let info: [String] = [
            "screenBounds: \(d.screenBounds)",
            "screenScale: \(d.screenScale)",
            "name: \(d.name)",
            "model: \(d.model)",
            "localized model: \(d.localizedModel)",
            "wristLocation: \(d.wristLocation.string)",
            "crownOrientation: \(d.crownOrientation.string)",
            "preferredContentSizeCategory: \(d.preferredContentSizeCategory)",
            "systemName: \(d.systemName)",
            "systemVersion: \(d.systemVersion)",
            "waterResistanceRating: \(d.waterResistanceRating.string)",
            "platform: \(self.platform)",
            "model: \(self.model)",
            "watch model name: \(MYWatchModel().string)"
        ]
        
        print(info.joined(separator: "\n"))
    }
}
```

Apple Watch Series 1は、Series 2と同時期に出た廉価版です。