     
     
     //MARK: Init
-    
     init(){
-
+        //Get all notifications from disk
         self.notifications = notificationArchiver.getNotifications()
-        
     }
     
     //MARK: Functions
+    //This function lets the user add a view that they want to be badged as app level notifications come through.
+    public func addViewToBadge(theView: UIView) {
+        //Create a new badger for the view and give it the default colors and pin it to the view the user pased in
+        let newBadger = Badger(badgeColor: nil, textColor: nil, viewToBadge: theView, initialValue: "\(UIApplication.sharedApplication().applicationIconBadgeNumber)")
+        //Append a newly created tuple to the array of views to badge
+        self.viewsToBadge.append((theView, newBadger))
+    }
+    
+    //This is the file notification function
     public func fireNotification(theNotification: Notification) {
-        
+        //This determines if we should fire this notification based on the debug flag
         if self.fireDebugNotifications == false && theNotification.debug == true {
             return
         }
-        
+        //This determines if we should fire the notificaiton based on the screened Notificaiton flag
         if self.fireScreenedNotifications == false && theNotification.screenedNotification == true {
             return
         }
-        
-        
+        //This increments the applicaiton icon badge number
         UIApplication.sharedApplication().applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
-        
+        //Call the method that refreses all the views that the user has said wants to know about applicaiton badge numbers
         self.refreshTabBarItem()
-        
+        //Create the system notificaton
         let notification = UILocalNotification()
+        //Give it the notificaiton a badge number
         notification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber
+        //Set the title to the notificaiton text
         notification.alertTitle = theNotification.text
+        //COnstruct the alert body
         if theNotification.text != nil && theNotification.expandedText != nil {
             notification.alertBody = theNotification.text! + " - " + theNotification.expandedText!
         }else{
             notification.alertBody = theNotification.expandedText
         }
+        //Set the user info
         notification.userInfo = theNotification.info
+        //Present local notificaiton
         UIApplication.sharedApplication().presentLocalNotificationNow(notification)
-        
+        //Save the notificaiton to disk
         self.notificationArchiver.saveNotification(theNotification)
+        //INsert the notificaiton into the managers array of notificaitons
         self.notifications.insert(theNotification, atIndex: 0)
+        //Alert the notification delegate that we fired a new notification
         self.notificationDelegate?.gotNewNotification(theNotification)
     }
     
+    
+    //Convenience method for a pop up notification
     public func popUpNotification(title: String, message: String?, viewThatWillPresentAlert view: UIViewController) {
+        //Create the alertController
         let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
-        
+        //Create the OK Action
         let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)
-        
+        //Add the action to the controller
         alertController.addAction(okAction)
-        
+        //Present the alert controller
         view.presentViewController(alertController, animated: true, completion: nil)
     }
     
+    
+    //Function to keep the badges on view synced to the application badge number
     public func refreshTabBarItem() {
+        //See if the application badge number is zero
         if UIApplication.sharedApplication().applicationIconBadgeNumber == 0 {
-            
-            switch self.viewToBadge {
-            case is UITabBarItem:
-                guard let tabBar = self.viewToBadge as? UITabBarItem else{
-                    return
-                }
-                
-                tabBar.badgeValue = ""
-            case is UIView:
-//                guard let view = self.viewToBadge as? UIView else{
-//                    return
-//                }
-                print("Is UIView")
-            default:
-                return
+            //If it is enumerate throught the view to badge
+            for (index, item) in self.viewsToBadge.enumerate() {
+                //Set the badger view to ""
+                item.aBadger.badgeValue = ""
             }
-            
-            
-            if self.viewToBadge is UITabBarItem {
-
+            //Loop through the tab bars to badge
+            for item in self.tabBarsToBadge {
+                //Set the value to nil
+                item.badgeValue = nil
             }
-
         }else{
-            
-            if self.viewToBadge is UITabBarItem {
-                guard let tabBar = self.viewToBadge as? UITabBarItem else{
-                    return
-                }
-                
-                tabBar.badgeValue = "\(UIApplication.sharedApplication().applicationIconBadgeNumber)"
+            //Do the same except set the value to the application badge number
+            for (index,item) in self.viewsToBadge.enumerate() {
+                item.aBadger.badgeValue = "\(UIApplication.sharedApplication().applicationIconBadgeNumber)"
             }
-
+            for item in self.tabBarsToBadge {
+                item.badgeValue = "\(UIApplication.sharedApplication().applicationIconBadgeNumber)"
+            }
         }
-        
     }
     
+    
+    //Delete all notificaitons
     public func deleteAllNotifications() {
         self.notifications = self.notificationArchiver.removeAllNotifications()
     }

//

import UIKit

private let debugKey = "Debug"
private let screenKey = "ScreenNotifications"

public protocol NewNotificationDelegate {
    func gotNewNotification(theNotification: Notification)
}

    public var notificationDelegate: NewNotificationDelegate?
    //Array Of notifications
    public var notifications = [Notification]()
    //Array of Tuples that keep a bagde view associated with a view that the uset wants badged. The user adds a new view that they wan badged throug the addViewToBadgeFunction.
    private var viewsToBadge: [(aView: UIView, aBadger: Badger)] = [(aView: UIView, aBadger: Badger)]()
    //Array of tab bars that the user wants badged
    public var tabBarsToBadge: [UITabBarItem] = [UITabBarItem]()
    //Variable to determine if we should fire debug notifications or not
    public var fireDebugNotifications = NSUserDefaults.standardUserDefaults().boolForKey(debugKey) {
        didSet {
