<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/init(frame:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)initWithFrame:"
  },
  "title" : "init(frame:)"
}
-->

# init(frame:)

Initializes and returns a newly allocated `NSView` object with a specified frame rectangle.

```
init(frame frameRect: NSRect)
```

## Parameters

`frameRect`

The frame rectangle for the created view object.

## Return Value

An initialized view or `nil` if AppKit couldn’t create the object.

## Discussion

Insert the view into your window’s view hieararchy before you can do anything with it. This method is the designated initializer for the [`NSView`](/documentation/AppKit/NSView) class.

## See Also

[`-  addSubview:positioned:relativeTo:`](/documentation/AppKit/NSView/addSubview(_:positioned:relativeTo:))

Inserts a view among the view’s subviews so it’s displayed immediately above or below another view.

[`frame`](/documentation/AppKit/NSView/frame)

The view’s frame rectangle, which defines its position and size in its superview’s coordinate system.

[`-  addSubview:`](/documentation/AppKit/NSView/addSubview(_:))

Adds a view to the view’s subviews so it’s displayed above its siblings.

  [View Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40002978)



---

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)