> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swiftui/data-flow/preferences/preferencekey/allvalues-less-than-t-greater-than.md).

# 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](/ios/swiftui/data-flow/preferences/preferencekey.md)
  {% endtab %}
  {% endtabs %}
