I am relatively new to XCode and I have a problem. In my UITableViewController I have an array with a list of tricks.
var trickListArray = [tricktionaryViewController.trick(category: "", name: "", turn: "", degree: 0, description: "", instruction: "")]
var learningListArray = [tricktionaryViewController.trick(category: "", name: "", turn: "", degree: 0, description: "", instruction: "")]
var myTricksArray:[[tricktionaryViewController.trick]] {
return [trickListArray,learningListArray]
}
I want to append objects of the class "trick" to this array from another ViewController through an "add to trick list" UIButton. After pressing this button a PopUp appears saying "Successfully added", but I don't want to segue to my UITableViewController, but simply append the trick object to my trickListArray or learningListArray and update my UITableView afterwards like this:
@IBAction func addToTrickList(sender: AnyObject) {
var destinationViewController: myTricksViewController = myTricksViewController(nibName: nil, bundle: nil)
destinationViewController.trickListArray.append(self.activeTrick)
var popUpTextString: String = "Successfully added " + String(activeTrick.name) + " to the list"
self.popViewController.showInView(self.view, animated: true, text: popUpTextString)
}
if I add a reloadData()
function in the IBAction like this:
@IBAction func addToTrickList(sender: AnyObject) {
var destinationViewController: myTricksViewController = myTricksViewController(nibName: nil, bundle: nil)
destinationViewController.trickListArray.append(self.activeTrick)
destinationViewController.myTricksTableView?.reloadData()
var popUpTextString: String = "Successfully added " + String(activeTrick.name) + " to the list"
self.popViewController.showInView(self.view, animated: true, text: popUpTextString)
}
it will not update the UITableView. I have not yet tested whether the array is really updated or not, but it should be.
Any help is appreciated!