雖然翻了文件但還是恍恍惚惚,完全沒有看懂 DeviceActivityName 到底在做什麼,就先附上做個紀錄吧QQ
字面上意義是,活動的唯一識別符。每個 DeviceActivityName 都需要有一個唯一的 string,同一時間內不能有多個 activity 使用相同的名稱。
此外,DeviceActivityName 也支持 rawValue 的概念,不過這是什麼請容我之後再補齊了。
/// The unique name of an activity.
///
/// Use `DeviceActivityName` to associate an activity with some of your application's data.
/// It's not possible to have multiple activities with the same name.
/// Monitoring a second activity with the same name as a previous activity overwrites the schedule for the first one.
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DeviceActivityName : RawRepresentable, Equatable, Hashable {
/// The corresponding value of the raw type.
///
/// A new instance initialized with `rawValue` will be equivalent to this
/// instance. For example:
///
/// enum PaperSize: String {
/// case A4, A5, Letter, Legal
/// }
///
/// let selectedSize = PaperSize.Letter
/// print(selectedSize.rawValue)
/// // Prints "Letter"
///
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
/// // Prints "true"
public var rawValue: String
/// Creates a new instance with the specified raw value.
///
/// - Parameters:
/// - rawValue: The raw value to use for the new instance.
public init(_ rawValue: String)
/// Creates a new instance with the specified raw value.
///
/// - Parameters:
/// - rawValue: The raw value to use for the new instance.
public init(rawValue: String)
/// The raw type that can be used to represent all values of the conforming
/// type.
///
/// Every distinct value of the conforming type has a corresponding unique
/// value of the `RawValue` type, but there may be values of the `RawValue`
/// type that don't have a corresponding value of the conforming type.
public typealias RawValue = String
}