     func cleanUpStatus()
     {
         let request = NSFetchRequest(entityName: "APPStatus")
-        request.predicate = NSPredicate(format: "date == nil")
+        request.predicate = NSPredicate(format: "date != nil")
         request.resultType = NSFetchRequestResultType.ManagedObjectIDResultType
         
         do

        }
        
        formatter = NSDateFormatter()
        formatter.dateFormat = "yyyy-MM-dd E HH:mm:ss"
        
        trackController = (window!.rootViewController as! UINavigationController).topViewController as! TrackTimeTableViewController
        trackController.managedObjectContext = managedObjectContext
        
        insertAPPStatus(APPStatusType.Launch)
        
//        cleanUpStatus()
        return true
    }
    

        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
        print(__FUNCTION__)
        trackController.enterBackgroundMode()
        insertAPPStatus(APPStatusType.EnterBackground)
    }

    func applicationWillEnterForeground(application: UIApplication)
