---
title: "init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)"
framework: photosui
role: symbol
role_heading: Initializer
path: "photosui/photospicker/init(_:selection:maxselectioncount:selectionbehavior:matching:preferreditemencoding:photolibrary:)-5tpfd"
---

# init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)

Creates a picker with a title key and selection from the photo library you specify, and optionally configures the max selection count, selection behavior, types of items to show, item encoding, and label behavior.

## Declaration

```swift
nonisolated init(_ titleKey: LocalizedStringKey, selection: Binding<[PhotosPickerItem]>, maxSelectionCount: Int? = nil, selectionBehavior: PhotosPickerSelectionBehavior = .default, matching filter: PHPickerFilter? = nil, preferredItemEncoding: PhotosPickerItem.EncodingDisambiguationPolicy = .automatic, photoLibrary: PHPhotoLibrary)
```

## Parameters

- `titleKey`: A string key that describes the purpose of showing the picker.
- `selection`: The items the picker displays in a selected state.
- `maxSelectionCount`: The maximum number of items available to select.
- `selectionBehavior`: The selection behavior of the picker.
- `filter`: The types of items that the picker shows.
- `preferredItemEncoding`: The encoding policy of the selection.
- `photoLibrary`: The photo library to select from.

## See Also

### Creating a picker with a title

- [init(_:selection:matching:preferredItemEncoding:)](photosui/photospicker/init(_:selection:matching:preferreditemencoding:)-7jbef.md)
- [init(_:selection:matching:preferredItemEncoding:)](photosui/photospicker/init(_:selection:matching:preferreditemencoding:)-48f7l.md)
- [init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)](photosui/photospicker/init(_:selection:maxselectioncount:selectionbehavior:matching:preferreditemencoding:)-8ac23.md)
- [init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)](photosui/photospicker/init(_:selection:maxselectioncount:selectionbehavior:matching:preferreditemencoding:)-6m11r.md)
- [init(_:selection:matching:preferredItemEncoding:photoLibrary:)](photosui/photospicker/init(_:selection:matching:preferreditemencoding:photolibrary:)-bu7c.md)
- [init(_:selection:matching:preferredItemEncoding:photoLibrary:)](photosui/photospicker/init(_:selection:matching:preferreditemencoding:photolibrary:)-6bm2n.md)
- [init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)](photosui/photospicker/init(_:selection:maxselectioncount:selectionbehavior:matching:preferreditemencoding:photolibrary:)-6fwsc.md)
