Question: I have to check each line of a file against another file.
If one line from the first file exists in the second file I have to delete it.
Right now i'm using 2 listboxes and the "for listbox1.items.count-1 downto do begin..."
My program works but I have to check this for huge files with over 1 milion lines.
Is there a faster approach to this method? 
I want to load the files inside memory in order to be extremely fast!
Thanks

Answer: 
You can use the `filter` functionality, and use `first` instead of `[0]`, to avoid crashes if the filtered array has no elements:

```
if let view = self.view.subviews.filter{ $0.tag == 1 }.first {

```
Swift 3 added the [`Sequence.first(where:)`](https://developer.apple.com/reference/swift/sequence/1849238-first) method, which can replace the calls to `filter` and `first` in [Cristik's answer](https://stackoverflow.com/a/34617434/116862).

The advantages of `first(where:)` over `filter { ... }.first` are (a) the code becomes marginally clearer and (b) more importantly, better performance when the array is large or the closure is expensive because it stops after finding the first match.

```
if let view = self.view.subviews.first { $0.tag == 1 } {
    ...
}

```