MutableCollection move(fromOffsets:toOffset:) cannot be called without importing SwiftUI

Hi everyone, recently I wanted to use functionality to move with IndexSet in collection as stated in documentation, but Xcode doesn't showed this function in autocomplete. It only appears after I've imported SwiftUI to the project, but documentation shows that is Standard Library function. I've also checked the Swift language repository MutableCollection file and it doesn't have that.

Is this intended behavior or it's documentation flaw?

I agree that the documentation is failing you here. It does make sense to me that the documentation for move(fromOffsets:toOffset:) is listed under MutableCollection (a standard library type), but it should say prominently in which module this extension is implemented.

Incidentally, I use the excellent Dash app as my documentation viewer and much prefer it over Xcode. And Dash does show the originating framework:

(I'm not affiliated with Dash in any way, but I very much endorse it.)

Thank you, now it makes sense :smiley:

1 Like