In the process of building a macOS application that will analyse data collected from an on-line database, which can then be used for local analysis. I am a radio hobbyist and want to compare two antennas I have built.
The data is collected into a delimited text file and the contents placed into an Array. I do this by:
@Observable
class DataModel {
var fileName = "No file selected"
var windowTitle = "WSPR Analysis "
var recordArray: [[String]] = []
}
func readTabDelimitedFile(atPath path: String) -> [[String]] {
do {
let fileContent = try String(contentsOfFile: path, encoding: .utf8)
let lines = fileContent.components(separatedBy: .newlines)
var parsedData: [[String]] = []
for line in lines {
if !line.isEmpty {
let values = line.components(separatedBy: "\t")
parsedData.append(values)
}
}
return parsedData
} catch {
print("Error reading file: \(error.localizedDescription)")
return [[""]]
}
}
The first row in the array will have the Header names
dataModel.recordArray[0]
While the remaining of the rows contain the data to displayed in the Table cells.
My problem is, I don’t understand how to populate the Table View and have the headers reflect what’s in dataModel.recordArray[0].
Can someone help me ?