<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/convert(_:from:)-40x0w",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)convertSize:fromView:"
  },
  "title" : "convert(_:from:)"
}
-->

# convert(_:from:)

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

```
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 [`NSWindow`](/documentation/AppKit/NSWindow) object, and that window must not be `nil`. If `view` is `nil`, this method converts from window coordinates instead.

## Return Value

The converted size, as an <doc://com.apple.documentation/documentation/Foundation/NSSize> structure.

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

[`contentView`](/documentation/AppKit/NSWindow/contentView)

The window’s content view, the highest accessible view object in the window’s view hierarchy.

[`ancestorShared(with:)`](/documentation/AppKit/NSView/ancestorShared(with:))

Returns the closest ancestor shared by the view and another specified view.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)