     var hkStore:HKHealthStore?
     
     var useMetric = false
+    
+    var isFirstLoad = true
 
     override func viewDidLoad() {
         super.viewDidLoad()

        }
        
        self.useMetric = self.defaults.stringForKey("distanceUnit") == "meters"
    }

    override func didReceiveMemoryWarning() {

            hkStore.executeQuery(query)
        }
    }
    
    func managedObject() -> NSManagedObject? {
        if let workout = self.workout, uuid = workout.UUID?.UUIDString {
            let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
            let managedContext = appDelegate.managedObjectContext!
            
            let fetchRequest = NSFetchRequest(entityName: "SyncLog")
            let predicate = NSPredicate(format: "uuid = %@", uuid)
            fetchRequest.predicate = predicate
            
            let fetchedEntities = managedContext.executeFetchRequest(fetchRequest, error: nil)
            
            if let syncLog = fetchedEntities?.first as? NSManagedObject {
                return syncLog
            }
        }
        
        return nil
    }
}
