Reputation: 1083
I have a working table populating data from an array declared as
var tableData:[AnyObject] = []
Here is the unwind function
@IBAction func unwindToVC(segue: UIStoryboardSegue) {
if(segue.sourceViewController .isKindOfClass(AddNewsViewController))
{
let data:AddNewsViewController = segue.sourceViewController as! AddNewsViewController
let newscontent = data.contentView.text
let newstitle = data.contentView.text
let author = data.contentView.author
let dateposted = data.contentView.dateposted
let icon = data.contentView.icon
let location = data.contentView.location
let description = data.contentView.description
self.tableData.append(
[
"title":newstitle,
"author":author,
"dateposted":date,
"icon":envelope,
"location":location,
"description":description
]
)
self.newsTable.reloadData()
print(self.tableData)
}
}
the log returns the array with the recently appended data, but the tableview is not reloading with the new details.
Upvotes: 0
Views: 1863
Reputation: 808
Call newsTable.reloadData()
in viewDidAppear
rather than in unwindToVC
. According to Apple:
For efficiency, the table view redisplays only those rows that are visible.
When unwindToVC
gets called none of the rows are visible yet.
Upvotes: 3