I'm trying to pass a dictionary from one ViewController to another, I succeeded, but the dictionary I'm passing is empty. I want to pass the dictionary after adding the userInput when I click the save (createFav) button
This is my ViewController where I'm picking up the user input and inserting into the dictionary:
var favsDictionary = [String: String]()
var rowsInSection = 1
@IBAction func createFav(sender: AnyObject) {
var userInputToTrimm = userInput.text
var trimmUserInput = userInputToTrimm.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
var zipInStr: String = zipCode.text!
//Este if/else confere se a entrada do usuario não é nulo
if (userInputToTrimm == String()){
println("Please insert a name")
} else if (trimmUserInput == String()) {
println("Please input a valid name")
} else {
favsDictionary[trimmUserInput] = zipInStr
}
}
And this is how I'm importing favsDict into the other View:
var cellDictionary = ViewController().favsDictionary