WWDetectDevice

main

Detect the device name and other related information from the device number.
William-Weng/WWDetectDevice

WWDetectDevice

Swift-5.6 iOS-14.0 TAG Swift Package Manager-SUCCESS LICENSE

dependencies: [
    .package(url: "https://github.com/William-Weng/WWDetectDevice.git", .upToNextMajor(from: "1.1.0"))
]

Function - 可用函式

函式 功能
deviceModelObject(type:) 取得該裝置類型的全文件資料 (iPad / iPhone / AppleTV / AppleWatch)
deviceModel(type:) 取得該裝置類型的全文件字典 (iPad / iPhone / AppleTV / AppleWatch)
deviceIdentifier() 取得該裝置的內部編號 (實機才可以)
deviceInformation(identifier:) 取得該單一裝置類型的資訊

Example

import UIKit
import WWPrint
import WWDetectDevice

// MARK: - ViewController
final class ViewController: UIViewController {

    private typealias Info = (type: DeviceType, identifier: String)
    
    private let identifiers: [String] = [
        "AppleTV6,2",
        "iPad5,4",
        "Watch6,9",
        WWDetectDevice.shared.deviceIdentifier(),
    ]
    
    /// 檢測裝置類型名稱
    /// - Parameter sender: UIButton
    @IBAction func detectDevice(_ sender: UIButton) {
        
        guard let identifier = identifiers[safe: sender.tag] else { return }
        
        let info = WWDetectDevice.shared.deviceInformation(identifier: identifier)
        sender.setTitle(info["name"] as? String, for: .normal)
    }
}

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Dec 05 2024 05:35:58 GMT-1000 (Hawaii-Aleutian Standard Time)