To filter an array in swift, you can use the filter method on the array.
main.swift146 chars7 linesThe closure passed to the filter method will return true for all elements that should be included in the resulting array. In this example, we are using the contains method on the selected array to check if the current number should be included in the notSelected array. The ! operator negates the result, so the filter method will include all numbers that are not selected.
gistlibby LogSnag