I have a 100mb log file that I separate by line and set as an NSArray. After I display the text in a NSTableView.
I want to be able to select a certain substring, find which cell has the substring and scroll to the cell.
What I have so far:
This is the array that holds the text from the 100mb log file separated by line.
var linesArray: NSArray = []
This is the substring that I want to find, keep in mind it is a substring. So the line may have other text in it.
var testSearchTerm: String = "1970-01-02"
I am able to find all the lines with the value, but it returns the line and I need the index so I can scroll to the index.
let filteredStrings = linesArray.filter { (item) -> Bool in
let asString = item as! String
var stringMatch = asString.range(of: testSearchTerm)
return stringMatch != nil ? true : false
}
How do I get the index from the function above, also is it possible to find the first instance of the substring, not all. Right now it gets every instance of the substring.