I can't get my UITableView to reload data in swift

JwL

I'm using a UITableView to list a number of settings with the state of that setting displayed in the cell title. When the cell is selected it segues to another view where I change the setting. I use a navigation control to go back to the UITableView however I'm unable to update the table

class OptionTable: UITableViewController{

var table : [[String:AnyObject]] = []
var data = NSMutableDictionary()

func dataFilePath() -> String {
    let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
    let documentsDirectory = paths[0] as NSString
    return documentsDirectory.stringByAppendingPathComponent("data.plist") as String
}

override func viewDidLoad() {
    super.viewDidLoad()
    data = NSMutableDictionary(contentsOfFile: self.dataFilePath())!
    table = data["table"] as [[String:AnyObject]] 
}
override func viewWillAppear(animated: Bool) {

    self.tableView.reloadData()

}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return table.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var rowTable : Dictionary = table[indexPath.row]
        cell.textLabel?.text = rowTable["Title"] as? String

        return cell
    }
}

The data is getting saved in the plist its just not being reloaded when I open the UITableView back up. The table does get reloaded when I go back another page then forwards again to the UITableView.

Why is self.tableView.reloadData() not working??? Any help would be greatly appreciated.

Rob

You may be saving the to the plist, but viewDidAppear is not loading it before refreshing the tableView.

Move the loading of the plist into viewDidAppear.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why is my Tableview data blank? I can't reload data

Swift UITableView On Reload Data

Can't reload UITableView

I can't get my array from JSON to load into the UITableView

I can't show data in UITableView

I can't get data and post it in my html

why I can't find get my data in Laravel blade

Why can't I get all data related to my model?

How can I get the height of a specific row in my UITableView

IOS Swift I can't get my real location from my app. I alway get the Apple Inc address

Reload UiTableView After Data Has Been Retrieved From Database - Swift

SQLite with swift , i can't get all elements from my table query

I can't use my core data model in two targets in a Swift project

why I can't access my 3rd level CoreData data in swift?

Swift Structure Extension Providing Get Only Data, and I can't Change the Data

I can't get my width to expand

I can't get my table responsive

I can't get my NSTableView updated

I can't get my crontab to work

Swifty JSON on swift can't get data

Swift I can't move data with delegate

How do I reload data in my TableView

UIView animation in UITableView doesn't work after reload data

WatchKit: Swift - How can I get and put data in my sqlite database that resides in my iPhone App documents folder

How can I pass data loaded when my application finished launching thru my UITabBar to a UITableView?

I can't get anything to install when running User Data for my EC2 instance

How can I ensure that my app's data doesn't get deleted when releasing an update?

I can't get the data from my server using reactjs and express

ParseQueryAdapter with Subclasses, android Why can't I get my data back from Parse?