Exchanging NSScrollView’s contentView

Trying to use a custom NSClipView in a NSScrollView. Noticed that it is not enough just to have this:

id docView = [myScrollView documentView];
MyClipView *clipView = [[MyClipView alloc] initWithFrame:[docView frame]];
[clipView setDocumentView:docView];
[myScrollView setContentView:clipView];

Because though this will instantiate a custom, subclassed NSClipView, afterwards the scrollbars won’t be clickable anymore. Instead, clicks will be forwarded to the document view of the scroll view (most likely a table view). It seems that the order of views inside the scroll view is broken and the scroll bar is visually in front of the document view, but behind it in terms of receiving mouse events. To fix this, add these lines at the end of the code example above:

NSScroller *scroller = [myScrollView verticalScroller];
[myScrollView setVerticalScroller:nil];
[myScrollView setVerticalScroller:scroller];

This will remove the vertical scroll bar from the scroll view and put it back again immediately. Do the same with the horizontal scroll bar if you have one. This operation will put the scroll bar in front of the document view, again, and everything will work. Not sure what the reason for this issue is, though, might by a Lion thing or some side effect of ARC.