---
title: "init(frame:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nsview/init(frame:)"
---

# init(frame:)

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

## Declaration

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

## Parameters

- `frameRect`: The frame rectangle for the created view object.

## Return Value

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

## Discussion

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 class.

## See Also

### Related Documentation

- [addSubview(_:positioned:relativeTo:)](appkit/nsview/addsubview(_:positioned:relativeto:).md)
- [frame](appkit/nsview/frame.md)
- [addSubview(_:)](appkit/nsview/addsubview(_:).md)
- [View Programming Guide](apple-archive/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction.md)

### Creating a view object

- [init(coder:)](appkit/nsview/init(coder:).md)
- [prepareForReuse()](appkit/nsview/prepareforreuse().md)
