Homam
Homam

Reputation: 5076

Track download progress from various ViewController

I have an app. It has VideoListViewController that has list of videos to download. When I click the download button, the control is transferred to DetailViewController. DetailViewController shows the download progress and when download gets completed, it plays the video. After download gets completed I changed isDownloaded to true, so that next time it shows play button instead of download.

Everything works perfectly if the user don't go to previous VideoListViewController while video is being downloaded. If it does go back to VideoListController, then I don't know the progress of download, neither when the download gets completed. Since from VideoListController I don't know when the download gets completed, I can't change the download button to play when the download gets completed.

Please help me to know how can one keep track of download progress and download completion event from various controllers or atleast from two different controller.

Do I need to keep the downloading function in AppDelegate. Please elaborate in detail. I am new to iOS

Upvotes: 0

Views: 135

Answers (1)

Amandir
Amandir

Reputation: 677

For Tasks like that Apple introduced the NSNotificationcenter.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html

With this you can make a thread notify different classes when it finished it's execution.

Upvotes: 1

Related Questions