Is it possible to iterate through an NSDictionary in a specific order so I can save an index for an key-value pair in CoreData, based on the order that the data is originally typed? i.e in the code below Set 1 would have an index of 1, set 2 - 2 and set 3 - 3 rather than at random, as is normal NSDictionary behaviour? Thanks in advance if anyone can either give a solution, or tell me its not possible!
let string1 = "rain, wait, train".wordsInArray
let string2 = "oil, join, coin".wordsInArray
let string3 = "made, came, same".wordsInArray
let lists: [String: [String]] =
["Set 1: List 1": string1,
"Set 1: List 2": string2,
"Set 1: List 3": string3]
var index = 0
For list in lists {
list.listIndex = index
index = index + 1
coreDataStack.saveMainContext()
}
extension String {
var wordsInArray:[String] {
return componentsSeparatedByCharactersInSet(NSCharacterSet.punctuationCharacterSet()).joinWithSeparator("").componentsSeparatedByString(" ")
}