Reputation:
The aim is to create a multidimensional array for the whole content of a textfile, which would be imported into CoreData.
The textfile have sections and under the sections are the the rows with the attributes of the table and value. Under Default in the switch, is a short Example of it.
I got the following error:
Could not find member 'subscript'
var stringArray = fullImportContent!.componentsSeparatedByString("\n")
var stringArrayCompleteData = Dictionary<String, Dictionary<String, Any>>()
var arrIndexSection : String
for singleRow in stringArray
{
if(singleRow != "")
{
switch singleRow {
case "#Header":
arrIndexSection = singleRow
case "#Objekt":
arrIndexSection = singleRow
case "#Baustelle":
arrIndexSection = singleRow
case "#Auftraggeber":
arrIndexSection = singleRow
case "#Architekt":
arrIndexSection = singleRow
case "#Vermittler":
arrIndexSection = singleRow
case "#Kontaktstellen":
arrIndexSection = singleRow
case "#Dateien":
arrIndexSection = singleRow
default:
//Here the multiple array would be filled
var arrSingleRow = singleRow.componentsSeparatedByString(";")
/*
Example how the Context could be in the textfile
#Objekt
Objektnr; 1000000;
*/
stringArrayCompleteData += [arrIndexSection][arrSingleRow[0]][arrSingleRow[1]]
println(singleRow)
}
}
}
How can i add the row in the "default" to the CompleteData-Array?
Upvotes: 0
Views: 66
Reputation: 4577
Since stringArrayCompleteData
is defined as Dictionary<String, Dictionary<String, Any>>
, you need to add a key-value pair like this:
stringArrayCompleteData[arrIndexSection] = [arrSingleRow[0]: arrSingleRow[1]]
Upvotes: 0