Reputation: 661
I am trying to switch an existing NSView with a new view loaded from nib file. I see there are two approaches to this
Remove my subview from super view and add the new subview to the super view.
[NSView]RemoveFromSuperView and [NSView]AddSubView
Replace my existing subview with the new subview using this call
[NSView] ReplaceSubviewWith(NSView, NSView)
Are these both calls the same ? Is there any significant advantage or difference in using one over the other ?
Upvotes: 1
Views: 565
Reputation: 889
If you are really swapping out one view for another use replaceSubview:with:
; after all, that's the exact job it was designed for! It's useful if you want the replacement view to be in the same place as the old view, and it's probably optimized a bit more for the subview replacement use case (I doubt that makes a huge difference though).
Upvotes: 1