0

Running into a strange problem:

I have a TableViewController (call it recent tab) that is one of the tabs of a UITabBarController. I have items getting saved into sandbox (documents folder) in the first tab bar (browse tab). I am then pulling them out in the second tab bar (recent) and setting them up in cellForRowAtIndexPath.

Here's the strange behavior: while I'm in first view controller (browse) adding items to the sandbox, everything works fine. I open the second tab (recent) that is the TableViewController and I see the items appear there. Then I try to go back to the first controller (browse) to add more items and they do not appear (when I go back to recent).

However, when I relaunch the application, the items I selected the second time do show up (in recent)!

I have tried to call tableView reloadData in recent (practically everywhere I could). I have tried to call [tableView beginUpdates].

No change, table view (for recent) updates properly only after restart of application.

Any suggestions?

Live2Enjoy7
  • 1,075
  • 2
  • 11
  • 22
  • nvm I ended up reworking the structure. I believe the issue was that the CellForRowAtIndexPath did not have an array with indexes to pull items out of, therefore causing tableView to have issues calculating how many rows there are (read this in another SO thread). – Live2Enjoy7 Nov 19 '12 at 02:17

1 Answers1

0

I believe the issue was that the CellForRowAtIndexPath did not have an array with indexes to pull items out of, therefore causing tableView to have issues calculating how many rows there are (read this in another SO thread).

The array has to already exist before CellForRowAtIndexPath is called, not be instantiated inside of it (could be passed to the class through a public api or instantiated in viewDidLoad for ex). Otherwise it will be instantiated every time CellForRowAtIndexPath is called and there will be no static index that could be used to create the cells.

Live2Enjoy7
  • 1,075
  • 2
  • 11
  • 22
  • I ran into the same issue in another instance and again putting things into array prior to CellForRowAtIndexPath getting called solved the issue. marking it as the answer – Live2Enjoy7 Nov 24 '12 at 21:56