# AllValues\<T>

{% tabs %}
{% tab title="📦  AllValues<T>" %}

```swift
// 2020.10.15：

import SwiftUI

// 📦 AllValues<T>
public struct AllValues<T>: PreferenceKey {
    // ⭐️ 收集的資料放在 [T] 裡面
    public typealias Value = [T]
    // ⭐️ 初始值：空陣列
    public static var defaultValue: Value { Value() }
    // ⭐️ 加入新資料的方法：[v1, v2, ...] + [vn]
    public static func reduce(value: inout Value, nextValue: () -> Value) {
        value += nextValue()   // nextValue() == [vn]
    }
}
```

{% endtab %}

{% tab title="👥  相關 " %}

* [🅿️ PreferenceKey](https://lochiwei.gitbook.io/ios/swiftui/data-flow/preferences/preferencekey)
  {% endtab %}
  {% endtabs %}
