In my application I have home screen which shows email listing in tableview. After click on any email we redirected to email detail screen where we can update status of email like dispute , paid and pending and also change the status from unread to read email.
After changing status of email on detail screen it is also want to update on email listing in tableview for that specific email when i pop from detail view to email listing.
struct NewHomeModel {
var body: String?
var date : String?
var dispute: Int?
var fileStatus: Int?
var from: String?
var msg_id: String?
var paid: Int?
var pending: Int?
var subject: String?
var thread_id: String?
var unread : Int?
var nextToken : String?
init(jsonData: [String: Any]) {
body = jsonData["body"] as? String ?? ""
date = jsonData["date"] as? String ?? ""
dispute = jsonData["dispute"] as? Int ?? 0
fileStatus = jsonData["fileStatus"] as? Int ?? 0
from = jsonData["from"] as? String ?? ""
msg_id = jsonData["msg_id"] as? String ?? ""
paid = jsonData["paid"] as? Int ?? 0
pending = jsonData["pending"] as? Int ?? 0
subject = jsonData["subject"] as? String ?? ""
thread_id = jsonData["thread_id"] as? String ?? ""
unread = jsonData["unread"] as? Int ?? 0
}}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if arrayData.count > 0 && arrayData.count > indexPath.row {
let objemail = arrayData.object(at: indexPath.row) as? NewHomeModel
let emailDetailVC = EmailDetailViewController()
emailDetailVC.strThreadId = (objemail?.thread_id)!
emailDetailVC.strTitle = (objemail?.subject)!
emailDetailVC.homeModel = objemail
self.navigationController?.pushViewController(emailDetailVC, animated: true)
}else{
print("array empty")
}
}