<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSRect",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@T@NSRect"
  },
  "title" : "NSRect"
}
-->

# NSRect

A rectangle.

```
typealias NSRect = CGRect
```

## Discussion

When building for 64 bit systems, or building 32 bit like 64 bit, `NSRect` is typedef’d to `CGRect`.

## Topics

### Managing Rectangles

[`NSContainsRect(_:_:)`](/documentation/Foundation/NSContainsRect(_:_:))

Returns a Boolean value that indicates whether one rectangle completely encloses another.

[`NSDivideRect(_:_:_:_:_:)`](/documentation/Foundation/NSDivideRect(_:_:_:_:_:))

Divides a rectangle into two new rectangles.

[`NSEqualRects(_:_:)`](/documentation/Foundation/NSEqualRects(_:_:))

Returns a Boolean value that indicates whether the two rectangles are equal.

[`NSIsEmptyRect(_:)`](/documentation/Foundation/NSIsEmptyRect(_:))

Returns a Boolean value that indicates whether a given rectangle is empty.

[`NSHeight(_:)`](/documentation/Foundation/NSHeight(_:))

Returns the height of a given rectangle.

[`NSInsetRect(_:_:_:)`](/documentation/Foundation/NSInsetRect(_:_:_:))

Insets a rectangle by a specified amount.

[`NSIntegralRect(_:)`](/documentation/Foundation/NSIntegralRect(_:))

Adjusts the sides of a rectangle to integer values.

[`NSIntegralRectWithOptions(_:_:)`](/documentation/Foundation/NSIntegralRectWithOptions(_:_:))

Adjusts the sides of a rectangle to integral values using the specified options.

[`NSIntersectionRect(_:_:)`](/documentation/Foundation/NSIntersectionRect(_:_:))

Calculates the intersection of two rectangles.

[`NSIntersectsRect(_:_:)`](/documentation/Foundation/NSIntersectsRect(_:_:))

Returns a Boolean value that indicates whether two rectangles intersect.

[`NSMakeRect(_:_:_:_:)`](/documentation/Foundation/NSMakeRect(_:_:_:_:))

Creates a new `NSRect` from the specified values.

[`NSMaxX(_:)`](/documentation/Foundation/NSMaxX(_:))

Returns the largest x coordinate of a given rectangle.

[`NSMaxY(_:)`](/documentation/Foundation/NSMaxY(_:))

Returns the largest y coordinate of a given rectangle.

[`NSMidX(_:)`](/documentation/Foundation/NSMidX(_:))

Returns the x coordinate of a given rectangle’s midpoint.

[`NSMidY(_:)`](/documentation/Foundation/NSMidY(_:))

Returns the y coordinate of a given rectangle’s midpoint.

[`NSMinX(_:)`](/documentation/Foundation/NSMinX(_:))

Returns the smallest x coordinate of a given rectangle.

[`NSMinY(_:)`](/documentation/Foundation/NSMinY(_:))

Returns the smallest y coordinate of a given rectangle.

[`NSMouseInRect(_:_:_:)`](/documentation/Foundation/NSMouseInRect(_:_:_:))

Returns a Boolean value that indicates whether the point is in the specified rectangle.

[`NSOffsetRect(_:_:_:)`](/documentation/Foundation/NSOffsetRect(_:_:_:))

Offsets the rectangle by the specified amount.

[`NSPointInRect(_:_:)`](/documentation/Foundation/NSPointInRect(_:_:))

Returns a Boolean value that indicates whether a given point is in a given rectangle.

[`NSRectFromString(_:)`](/documentation/Foundation/NSRectFromString(_:))

Returns a rectangle from a text-based representation.

[`NSStringFromRect(_:)`](/documentation/Foundation/NSStringFromRect(_:))

Returns a string representation of a rectangle.

[`NSRectFromCGRect(_:)`](/documentation/Foundation/NSRectFromCGRect(_:))

Returns an `NSRect` typecast from a `CGRect`.

[`NSRectToCGRect(_:)`](/documentation/Foundation/NSRectToCGRect(_:))

Returns a `CGRect` typecast from an `NSRect`.

[`NSUnionRect(_:_:)`](/documentation/Foundation/NSUnionRect(_:_:))

Calculates the union of two rectangles.

[`NSWidth(_:)`](/documentation/Foundation/NSWidth(_:))

Returns the width of the specified rectangle.

### Zero Constant

[`NSZeroRect`](/documentation/Foundation/NSZeroRect)

An `NSRect` structure set to `0` in width and height.

### Constants

  <doc:nsrect/nsminxedge>

  <doc:nsrect/nsminyedge>

  <doc:nsrect/nsmaxxedge>

  <doc:nsrect/nsmaxyedge>

### Related Types

[`NSRectEdge`](/documentation/Foundation/NSRectEdge)

[`AlignmentOptions`](/documentation/Foundation/AlignmentOptions)

Values representing alignment operations.

[`NSRectArray`](/documentation/Foundation/NSRectArray)

Type indicating a parameter is array of `NSRect` structures.

[`NSRectPointer`](/documentation/Foundation/NSRectPointer)

Type indicating a parameter is a pointer to an `NSRect` structure.



---

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)