# SectionBy Structure Reference

# SectionBy

    @available(OSX 10.12, *)
    public struct SectionBy<D> where D : DynamicObject

The `SectionBy` clause indicates the key path to use to group the `ListMonitor` objects into sections. An optional closure can also be provided to transform the value into an appropriate section name:

    let monitor = CoreStore.monitorSectionedList(
        From<Person>(),
        SectionBy("age") { "Age \($0)" },
        OrderBy(.ascending("lastName"))
    )

- `init(_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections

  #### Declaration

  Swift

      public init(_ sectionKeyPath: KeyPathString)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections

- `init(_:_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections, and a closure to transform the value for the key path to an appropriate section name

  Important

  Some utilities (such as `ListMonitor`s) may keep `SectionBy`s in memory and may thus introduce retain cycles if reference captures are not handled properly.

  #### Declaration

  Swift

      public init(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections
  `sectionIndexTransformer` | a closure to transform the value for the key path to an appropriate section name

### CustomDebugStringConvertible

- `debugDescription`

  #### Declaration

  Swift

      public var debugDescription: String { get }

### SectionBy

- `init(_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, T>)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections

- `init(_:_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections, and a closure to transform the value for the key path to an appropriate section name

  Important

  Some utilities (such as `ListMonitor`s) may keep `SectionBy`s in memory and may thus introduce retain cycles if reference captures are not handled properly.

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, T>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections
  `sectionIndexTransformer` | a closure to transform the value for the key path to an appropriate section name

### SectionBy

- `init(_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Required<T>>) where T : ImportableAttributeType

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections

- `init(_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Optional<T>>) where T : ImportableAttributeType

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections

- `init(_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Required<T>>) where T : NSCoding, T : NSCopying

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections

- `init(_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>) where T : NSCoding, T : NSCopying

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections

- `init(_:_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections, and a closure to transform the value for the key path to an appropriate section name

  Important

  Some utilities (such as `ListMonitor`s) may keep `SectionBy`s in memory and may thus introduce retain cycles if reference captures are not handled properly.

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections
  `sectionIndexTransformer` | a closure to transform the value for the key path to an appropriate section name

- `init(_:_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections, and a closure to transform the value for the key path to an appropriate section name

  Important

  Some utilities (such as `ListMonitor`s) may keep `SectionBy`s in memory and may thus introduce retain cycles if reference captures are not handled properly.

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections
  `sectionIndexTransformer` | a closure to transform the value for the key path to an appropriate section name

- `init(_:_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections, and a closure to transform the value for the key path to an appropriate section name

  Important

  Some utilities (such as `ListMonitor`s) may keep `SectionBy`s in memory and may thus introduce retain cycles if reference captures are not handled properly.

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections
  `sectionIndexTransformer` | a closure to transform the value for the key path to an appropriate section name

- `init(_:_:)`

  Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections, and a closure to transform the value for the key path to an appropriate section name

  Important

  Some utilities (such as `ListMonitor`s) may keep `SectionBy`s in memory and may thus introduce retain cycles if reference captures are not handled properly.

  #### Declaration

  Swift

      public init<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?)

  #### Parameters

  `sectionKeyPath` | the key path to use to group the objects into sections
  `sectionIndexTransformer` | a closure to transform the value for the key path to an appropriate section name