Here’s another way to accomplish this that’s a bit more clear and succinct:
[viewToBeMadeForemost removeFromSuperview];
[self addSubview:viewToBeMadeForemost positioned:NSWindowAbove relativeTo:nil];
Per the documentation for this method, when you use relativeTo:nil
the view is added above (or below, with NSWindowBelow
) all of its siblings.