TabBarBadgeCount

This commit is contained in:
Chris Li 2016-08-29 10:03:41 -04:00
parent 4ff054f0e5
commit 8714e2cf7d
3 changed files with 9 additions and 2 deletions

View File

@ -22,6 +22,7 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController
tabBarItem.title = LocalizedStrings.LibraryTabTitle.download tabBarItem.title = LocalizedStrings.LibraryTabTitle.download
tabBarItem.image = UIImage(named: "Download") tabBarItem.image = UIImage(named: "Download")
tabBarItem.selectedImage = UIImage(named: "DownloadFilled") tabBarItem.selectedImage = UIImage(named: "DownloadFilled")
refreshTabBarBadgeCount()
} }
override func viewDidLoad() { override func viewDidLoad() {
@ -77,6 +78,11 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController
} }
} }
func refreshTabBarBadgeCount() {
guard let count = fetchedResultController.fetchedObjects?.count else {return}
tabBarItem.badgeValue = count > 0 ? "\(count)" : nil
}
// MARK: - TableView Data Source // MARK: - TableView Data Source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int { override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
@ -214,6 +220,7 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController
func controllerDidChangeContent(controller: NSFetchedResultsController) { func controllerDidChangeContent(controller: NSFetchedResultsController) {
tableView.endUpdates() tableView.endUpdates()
refreshTabBarBadgeCount()
} }
} }

View File

@ -49,7 +49,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.7.1481</string> <string>1.7.1486</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.7.1833</string> <string>1.7.1839</string>
<key>NSExtension</key> <key>NSExtension</key>
<dict> <dict>
<key>NSExtensionMainStoryboard</key> <key>NSExtensionMainStoryboard</key>