Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableViewCell unique identifier?
    text
    copied!<p>I'm looking for a way to uniquely identify instances of UITableViewCells even after they have been recycled (dequeued) via <a href="http://docs.go-mono.com/index.aspx?link=M%3aMonoTouch.UIKit.UITableView.DequeueReusableCell%28System.String%29" rel="nofollow">DequeueReusableCell(string identifier)</a> - without subclassing or using a container object.</p> <p>So basically, when I create a new cell, I want to use a unique id of this cell as a key to store another related object in a dictionary. Later on, when the cell get's recycled/dequeued, I want to read the related objected from the dictionary. <em>I am totally aware that the recycled cell may be placed at any index path in the table and may (most likely) contain other data than before - the other object really is related to the cell instance, not the index path.</em></p> <p>Loosing relation to the object must be avoided. The obtained id must at all cost be the same that was used when the cell was created.</p> <p>This was previously achieved by generating a random number and storing it as the cell's tag. However, those tags could collide (when the same random number is generated twice) and I would only want to implement collision avoidance as a last resort. So I'm looking for a better way.</p> <p>I've looked at <a href="http://docs.go-mono.com/monodoc.ashx?link=P%3aMonoTouch.Foundation.NSObject.ClassHandle" rel="nofollow">ClassHandle</a>, <a href="http://docs.go-mono.com/monodoc.ashx?link=P%3aMonoTouch.Foundation.NSObject.Handle" rel="nofollow">Handle</a> and <a href="http://docs.go-mono.com/monodoc.ashx?link=P%3aMonoTouch.Foundation.NSObject.SuperHandle" rel="nofollow">SuperHandle</a> properties. The only one staying consistent among dequeues seems to be the ClassHandle.</p> <p>Is it safe to use the ClassHandle property for this purpose? If not, what other options are there?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload