Do I have to keep explicit references for return values from GetCell() and GetViewForHeader() in UITableViewSource in MonoTouch?
I remember that it was (still is?) necessary in MonoTouch to keep explicit references to UITableViewCells returned by UITableViewSource.GetCell() to avoid collection of the managed cells. Wit regards to this issue, I have some questions:
- As of MonoTouch 5.2.12: is it still required to keep an ArrayList() with the managed cells created and returned be GetCell()?
- If I use Storyboards and dynamic cell prototypes, I never explicitly create a UITableViewCell but use DequeueReusableCell() only. What about this case?
- What about GetViewForHeader()? Do I have to keep references to the views I return from that method? Or is MonoTouch internally taking care of this?
As far as I know, the only scenario where you need to hold a reference to individual cells is if you have both a delegate on them and the cell is not a custom class.
If you subclass UITableViewCell, you shouldn't need to hold any references.
If you don't set any delegates, you also shouldn't need to hold any references.
If it's any help, MonoTouch.Dialog doesn't keep a reference to the Cell either, atleast not that I recall seeing!. Just makes it and passes it on. (posted on the question, too)
thinking about it, you should NOT keep references to cells, because they are designed to be reused.... so you may not get the same cell back in the next GetCell / GetCellForReuse type call.