I'm doing some lazy image loading for thumbnails to be displayed in a table. I have a class that lo开发者_开发知识库ads the image for me asynchronously...but my problem (or at least, a problem) is that by the time the image loads, I have no idea whether the cell that initiated the image load even exists anymore. Is there a way for me to test to see if a particular object reference is valid before I call it?
Thanks.
Not easily or reliably. This is really more of a design problem on your part which could conceivably have many different solutions. My first inclination would be to give the loader some sort of index or hash value rather than a pointer to a live object and tell it to go find the right cell when it's done.
精彩评论