Instance Property

superview

The view that is the parent of the current view.

Declaration

@property(readonly, assign) NSView *superview;

Discussion

The superview is the immediate ancestor of the current view. The value of this property is nil when the view is not installed in a view hierarchy. To set the value of this property, use the addSubview: method to embed the current view inside another view.

When checking the value of this property iteratively or recursively, be sure to compare the superview object to the content view of the window to avoid proceeding out of the view hierarchy.

See Also

Managing the View Hierarchy

subviews

The array of views embedded in the current view.

window

The view’s window object, if it is installed in a window.

- addSubview:

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

- addSubview:positioned:relativeTo:

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

- didAddSubview:

Overridden by subclasses to perform additional actions when subviews are added to the view.

- removeFromSuperview

Unlinks the view from its superview and its window, removes it from the responder chain, and invalidates its cursor rectangles.

- removeFromSuperviewWithoutNeedingDisplay

Unlinks the view from its superview and its window and removes it from the responder chain, but does not invalidate its cursor rectangles to cause redrawing.

- replaceSubview:with:

Replaces one of the view’s subviews with another view.

- isDescendantOf:

Returns YES if the view is a subview of a given view or if it’s identical to that view; otherwise, it returns NO.

opaqueAncestor

The view’s closest opaque ancestor, which might be the view itself.

- ancestorSharedWithView:

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

- sortSubviewsUsingFunction:context:

Orders the view's immediate subviews using the specified comparator function.

- viewDidMoveToSuperview

Informs the view that its superview has changed (possibly to nil).

- viewDidMoveToWindow

Informs the view that it has been added to a new view hierarchy.

- viewWillMoveToSuperview:

Informs the view that its superview is about to change to the specified superview (which may be nil).

- viewWillMoveToWindow:

Informs the view that it’s being added to the view hierarchy of the specified window object (which may be nil).

- willRemoveSubview:

Overridden by subclasses to perform additional actions before subviews are removed from the view.

enclosingMenuItem

The menu item containing the view or any of its superviews in the view hierarchy.