---
title: "runModal(for:modalDelegate:didEnd:contextInfo:)"
framework: Collaboration
role: symbol
role_heading: Instance Method
platforms: [macOS 10.5+]
path: "collaboration/cbidentitypicker/runmodal(for:modaldelegate:didend:contextinfo:)"
---

# runModal(for:modalDelegate:didEnd:contextInfo:)

Runs the receiver modally as a sheet attached to a specified window.

## Declaration

```swift
func runModal(for window: NSWindow, modalDelegate delegate: Any?, didEnd didEndSelector: Selector?, contextInfo: UnsafeMutableRawPointer?)
```

## Parameters

- `window`: The parent window for the sheet.
- `delegate`: The delegate for the modal session.
- `didEndSelector`: A message sent to the delegate after the user responds but before the sheet is dismissed.
- `contextInfo`: Contextual data passed to the delegate in the didEndSelector message.

## Discussion

Discussion The didEndSelector parameter is a selector that takes three arguments. The corresponding method should have a declaration modeled on the following example: - (void)identityPickerDidEnd:(CBIdentityPicker *)identityPicker returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; where the identityPicker argument is the identity picker object, the returnCode argument  is the button the user clicked, and contextInfo is the same contextInfo argument that was passed in the original message.

## See Also

### Related Documentation

- [Identity Services Programming Guide](apple-archive/documentation/Networking/Conceptual/IdentityServices_ProgGuide/Introduction.md)

### Running an Identity Picker

- [runModal(for:completionHandler:)](collaboration/cbidentitypicker/runmodal(for:completionhandler:).md)
- [runModal()](collaboration/cbidentitypicker/runmodal().md)
