ios - Swift Refresh TableView after creation -


in swift have 2 view controllers. 1 tableview , displays data array. on function call other view controller calls tableview , delivers arguments new data table view. when update array buckets data taken tableview doesn't update. how program reload data?

table view

import foundation import uikit class buckettableviewcontroller: uitableviewcontroller {     var buckets = ["a", "b", "c"]     override func viewdidload() {     }     override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {         return buckets.count     }      override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         var cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! uitableviewcell         cell.textlabel?.text = buckets[indexpath.row]         return cell     }     func updatebuckets(newbucket: nsarray) {         buckets = newbucket as! [string]         self.tableview?.reloaddata()     }  } 

i can verify updatebuckets called other view controller.

other view controller

    var bigarray = ["m", "a", "r", "c"]  override func viewdidload() {     super.viewdidload()     let buckets = buckettableviewcontroller()     buckets.updatebuckets(bigarray)  } 

try using tableview?.beginupdates() , tableview?.endupdates() instead - i've found tableview?.reloaddata() can finicky data source updates sometimes.

otherwise, make sure you're calling updatebuckets() on right instance of buckettableviewcontroller(); looks instantiated new instance in viewdidload() instead of changing content of existing instance (as presumably doing).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -