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


(Zhao Xin) #1

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