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

# convert(_:from:)

Converts a size from another view’s coordinate system to that of the view.

## Declaration

```swift
func convert(_ size: NSSize, from view: NSView?) -> NSSize
```

## Parameters

- `size`: The size (width and height) in view’s coordinate system.
- `view`: The view with size 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 size, as an NSSize structure.

## Discussion

Discussion The returned NSSize values are always forced to have positive a width and height. You can also use this method to get a view’s current magnification or zoom level, if it’s been changed from the default scale. Specifically, if you convert a known size from the window’s base coordinate space to that of view, the result is the current zoom level.

## 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)
