 @available(iOS 9.0, *)
 public extension HKSample {
     public var numeralValue: Double? {
-        guard defaultUnit != nil else {
+        guard hkType?.defaultUnit != nil else {
             return nil
         }
         switch sampleType {

    }

    public var numeralValue: Double? {
        guard defaultUnit != nil && quantity != nil else {
            return nil
        }
        return quantity!.doubleValueForUnit(defaultUnit!)
    }
    @available(iOS 9.0, *)
    public var defaultUnit: HKUnit? { return quantityType.defaultUnit }

    public var hkType: HKSampleType? { return quantityType }

    public func unitForSystem(metric: Bool) -> HKUnit? {
        return quantityType.unitForSystem(metric: metric)
    }
}

/*

            aCoder.encodeObject(aggregate!.startDate,      forKey: "startDate")
            aCoder.encodeObject(aggregate!.endDate,        forKey: "endDate")
            aCoder.encodeObject(aggregate!.numeralValue,   forKey: "numeralValue")
            aCoder.encodeObject(aggregate!.hkType,         forKey: "hkType")
            aCoder.encodeObject(aggregate!.aggOp.rawValue, forKey: "aggOp")
            aCoder.encodeObject(aggregate!.runningAgg,     forKey: "runningAgg")
