Hey all, here’s the deal…
I’ve got a UIImage that is being loaded in the background via an NSURLConnection within a subclassed UIImageView. Until the data finishes downloading, a placeholder image is shown. The UIImage needs to be used by another, separate UIImageView, as well.
The problem I’m having is that if I set the second UIImageView‘s image property to that of the subclassed object before the download is complete, the second UIImageView never displays the downloaded image, since it’s image prop is pointing to the placeholder.
Is there anyway to pass a pointer to a pointer between these two UIImageViews?
I’ve tried things like this:
imageView2.image = &[imageView1 image];
imageView2.image = *[imageView1 image];
But these don’t seem to work. Any ideas?
Those pointers look particularly gross. The problem with doing it that way is that, even though you might be updating the data pointed to by those pointers, you are not notifying your
UIImageViewsubclasses that the data has changed, and thus they don’t know to redraw.Instead of playing with that pointer mess, why not use Key-Value Observing instead? If you have a separate thread running that downloads the
UIImage, you can just tell yourUIImageViews to observe that property and when your downloader class is finished downloading all the data and has put it into the property, the views will get a notification and can then display the image.