What is the best way to add an item to an array on one VC and then use "prepare for segue" to transfer the array to another VC? So far this is what I have managed to come up with: (VC1)
var items: [String] = ["Hello"]
(VC2):
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
var destViewController: ViewController = segue.destination as! ViewController
destViewController.items = [textField.text!]
items.append(textField.text!)
}
On VC2 an error is coming up that states, "use of unresolved identifier" on the line
items.append(textField.text!)
destViewController.items = [textField.text!]and replace it withdestViewController.items.append(textField.text!- D. Murphyitems.appendit will look into the properties of VC2 and since it won't find anything it wouldn't know how to handle. This is the definition of Object Oriented Programming. Thought the beauty is if you have created another object, you can call on itself its properties sodestViewController.items.apped(textField.text!)would work for you. - mfaani