---
title: "convert(_:from:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/convert(_:from:)-7fbb6"
---

# convert(_:from:)

Converts a rectangle from the coordinate system of another view to that of the view.

## Declaration

```swift
func convert(_ rect: NSRect, from view: NSView?) -> NSRect
```

## Parameters

- `rect`: The rectangle in the view coordinate system.
- `view`: The view with rect in its coordinate system. Both view and the view must belong to the same doc://com.apple.appkit/documentation/AppKit/NSWindow object, and that window must not be nil. If view is nil, this method converts from window coordinates instead.

## Return Value

Return Value The converted rectangle.

## See Also

### Related Documentation

- [contentView](appkit/nswindow/contentview.md)
- [ancestorShared(with:)](appkit/nsview/ancestorshared(with:).md)

### Converting Coordinate Values

- [backingAlignedRect(_:options:)](appkit/nsview/backingalignedrect(_:options:).md)
- [convertFromBacking(_:)](appkit/nsview/convertfrombacking(_:)-229ps.md)
- [convertToBacking(_:)](appkit/nsview/converttobacking(_:)-2xx45.md)
- [convertFromLayer(_:)](appkit/nsview/convertfromlayer(_:)-3nsbu.md)
- [convertToLayer(_:)](appkit/nsview/converttolayer(_:)-44u7d.md)
- [convertFromBacking(_:)](appkit/nsview/convertfrombacking(_:)-2njpa.md)
- [convertToBacking(_:)](appkit/nsview/converttobacking(_:)-3zors.md)
- [convertFromLayer(_:)](appkit/nsview/convertfromlayer(_:)-8s5bi.md)
- [convertToLayer(_:)](appkit/nsview/converttolayer(_:)-160pw.md)
- [convertFromBacking(_:)](appkit/nsview/convertfrombacking(_:)-4agf9.md)
- [convertToBacking(_:)](appkit/nsview/converttobacking(_:)-4ra9y.md)
- [convertFromLayer(_:)](appkit/nsview/convertfromlayer(_:)-3usqp.md)
- [convertToLayer(_:)](appkit/nsview/converttolayer(_:)-2vozx.md)
- [convert(_:from:)](appkit/nsview/convert(_:from:)-1dq9l.md)
- [convert(_:to:)](appkit/nsview/convert(_:to:)-6u9ir.md)
