开发者

Testing if Cocoa object references are valid?

开发者 https://www.devze.com 2022-12-15 07:07 出处:网络
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 th

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消