I'm reading from a file with the following data:
-LX-A7q4_8kFE4I_-iip,1
-LWyCOhwO_lUwMt-dOOa,1
-LWwVCZL5sfQYd4WtSHw,1
Each row is separated by "\n", and each element is separated by a comma.
I am able to read the file, put the contents into an array, with the correct rows and columns.
I am then able to filter the array to remove the row I want. Finally, I want to write the array back to the file in the same format. The code I have is as follows:
// This filters the array and gets me the rows I want.
func writeToFile() {
let filteredMessageID = result.filter { $0.messageID != nominationKeyForReadStatus }
//This is my attempt at converting the array to a string, before I try writing the string back to the file.
let filteredMessageIDJoinedString = filteredMessageID.joined(separator:"\n")
}
This last bit of code is clearly wrong, as my array, returned after filtering as filteredMessageID is as follows:
// ▿ 2 elements
▿ 0 : 2 elements
- messageID : "-LWyCOhwO_lUwMt-dOOa"
- readStatus : "1"
▿ 1 : 2 elements
- messageID : "-LWwVCZL5sfQYd4WtSHw"
- readStatus : "1"
How do I convert filteredMessageID back to a string that looks like this?
"-LWyCOhwO_lUwMt-dOOa,1\n-LWwVCZL5sfQYd4WtSHw,1"
Thanks in advance!