---
title: "PMSessionCreatePrinterList(_:_:_:_:)"
framework: applicationservices
role: symbol
role_heading: Function
path: applicationservices/1460119-pmsessioncreateprinterlist
---

# PMSessionCreatePrinterList(_:_:_:_:)

Creates a list of printers available in the specified printing session.

## Declaration

```swift
func PMSessionCreatePrinterList(_ printSession: PMPrintSession, _ printerList: UnsafeMutablePointer<Unmanaged<CFArray>?>, _ currentIndex: UnsafeMutablePointer<CFIndex>?, _ currentPrinter: UnsafeMutablePointer<PMPrinter?>?) -> OSStatus
```

## Parameters

- `printSession`: The printing session whose printer list you want to obtain.
- `printerList`: A pointer to your doc://com.apple.corefoundation/documentation/CoreFoundation/CFArray variable. On return, the variable refers to a Core Foundation array containing a list of printers available in the specified printing session. Each element in the array is a Core Foundation string that contains a printer’s name as shown in the user interface. You are responsible for releasing the array.
- `currentIndex`: A pointer to your doc://com.apple.corefoundation/documentation/CoreFoundation/CFIndex variable. On return, the variable contains a value specifying where the current printer is in the printer list.
- `currentPrinter`: A pointer to your doc://com.apple.documentation/documentation/applicationservices/pmprinter variable. On return, the variable refers to a printer object that represents the current printer. You should not release the printer object without first retaining it. If the printer is the generic printer, the variable is set to NULL.

## Return Value

Return Value A result code. See Result Codes.

## Discussion

Discussion You must call this function between the creation and release of a printing session. See the function PMCreateSession(_:).  You can call the function PMSessionCreatePrinterList to obtain a valid printer name to pass to the function PMSessionSetCurrentPrinter. Special Considerations In macOS 10.2 and later, Apple recommends using the function PMServerCreatePrinterList(_:_:) instead. PMServerCreatePrinterList doesn’t require a PMSession object; it can be called at any time. It also works directly with PMPrinter objects.

## See Also

### Creating Printer Objects

- [PMServerLaunchPrinterBrowser(_:_:)](applicationservices/1460175-pmserverlaunchprinterbrowser.md)
- [PMServerCreatePrinterList(_:_:)](applicationservices/1459953-pmservercreateprinterlist.md)
- [PMPrinterCreateFromPrinterID(_:)](applicationservices/1461363-pmprintercreatefromprinterid.md)
- [PMCreateGenericPrinter(_:)](applicationservices/1461960-pmcreategenericprinter.md)
