[swift-users] Is there an equivalence method on `NSArray`'s `func objects(at indexes: IndexSet) -> [Any]` in Array?

Zhao Xin owenzx at gmail.com
Thu Oct 6 19:06:01 CDT 2016


I managed to do that by using `map` as I didn't find the equivalence.

files.forEach {

    var indices = IndexSet()



    for index in 0 ..< subtitleFiles.count {

        if $0.sn == subtitleFiles[index].sn {

            indices.insert(index)

        }

    }



    let subtitles = indices.map { return subtitleFiles[$0] } // get array
at IndexSet

    videoSubtitles.updateValue(subtitles, forKey: $0)

    indices.reversed().forEach { subtitleFiles.remove(at: $0) } // remove
elements at IndexSet

}


Is there a better way to do that?


Zhaoxin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161007/76c3932d/attachment.html>


More information about the swift-users mailing list