2

I have an application that imports an XML file at first launch to create a table. This worked perfectly fine in iOS 9. In iOS 10, it still imports all the data correctly, and performs the fetch correctly, but the table won't show the items until I force quit the app and open it again. Instead it just shows the first item from the xml file. When I click on the item, it actually takes me to the first item in the ordered list of 298 items (which is a different item).

Link to video showing issue: reloading table issues

Order:

  • 1) App opens on initial launch, prompts user to "import data". Parser is used to import XML and successfully runs through XML (I can print a log of each item).
  • 2) App saves the importContext and calls tableView.reloadData
  • 3) At this point, data should be in table. Navigation title includes a count, which is correct (298 items). However, only 1 item is in the table, the first item from the XML file.
  • 4) If I click on that item, it takes me to what would be the first item in the list of 298 items (NOT the item actually in the table).
  • 5) Interestingly, if I perform a search, the name of the 1 item doesn't change, but if I click on it, it takes me to the item I searched for. If I search for a different item and click on the 1 item in the table, it takes me to the new item (but still never changes the text of the existing item) - so all 298 items are there, just not showing in the table.

I've tried calling

self.viewDidLoad

and

self.tableView.reloadData()

and

dispatch_async(dispatch_get_main_queue()) {
            self.tableView.reloadData()
        }

and calling all three above functions using the NSNotificationCenter AFTER the parsing is complete with

NSNotificationCenter.defaultCenter().postNotificationName("performFetch", object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.test), name: "performFetch", object: nil)

But nothing actually resets the one item in the tableView (which happens to be the first item in the xml file. Again, all the data is there, just invisible.

If I force quit the app and open it back up, all the data is there and visible and works just fine. Is there a different/new way to force a tableview refresh in iOS 10? Again, this feature worked fine in ios 9, no code changed, but in ios 10 it fails. I have not upgraded to Swift 3.0 because it is going to be a pain.

Zachary Fisher
  • 781
  • 1
  • 7
  • 18
  • 1
    Having a similar issue with iOS 10.0.2 (it actually started happening with this version), but if I scroll the table, it loads (with some glitches, but it does). – diogocarmo Sep 23 '16 at 20:50
  • @dccarmo by glitch do you mean repeating data? thats the issue im dealing with now – highboi Dec 20 '16 at 14:16
  • @Multinerd I don't quite remember, but I don't think it was repeating data. – diogocarmo Dec 22 '16 at 19:11

1 Answers1

0

You do your cell configuration in cellForRowAtIndexPath: method? I had a similar problem and i solved it moving the code in willDisplayCell:.

Sakis
  • 59
  • 1
  • 4
  • 1
    Perhaps you could take the time to post a little example of the code you used, it would improve your answer. – miltonb Dec 28 '16 at 23:29