I am downloading images using NSOperationQueue.
I want to call a method reloadView
of my view controller once the image download is complete.
However when the download is in progress, it is fairly possible that user has moved to a different view. This other view will also have a reloadView
method (eg first view shows total downloaded images count, and second shows thumbnails of download images)
Basically what I want is that whenever an image download is completed, I should be able to call the reloadView
method of the active view controller whichever it is?
How can this be possible?
I wouldn't take that approach. This is the kind of thing NSNotificationCenter
is designed for. When your image has finished downloading, post a notification. In view controllers that need to know about it, listen for the notification in viewDidAppear:
and stop listening in viewDidDisappear:
. Your downloading code doesn't need to know the details of your view controllers or their status.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.