File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -484,14 +484,18 @@ struct LabeledQuantity: View {
484484 }
485485
486486 var valueText : Text {
487+ guard let quantity = quantity else {
488+ return Text ( " -- " )
489+ }
490+
487491 let formatter = QuantityFormatter ( )
488492 formatter. setPreferredNumberFormatter ( for: unit)
489493
490494 if let maxFractionDigits = maxFractionDigits {
491495 formatter. numberFormatter. maximumFractionDigits = maxFractionDigits
492496 }
493497
494- guard let string = formatter. string ( from: quantity ?? HKQuantity ( unit : unit , doubleValue : 0 ) , for: unit) else {
498+ guard let string = formatter. string ( from: quantity, for: unit) else {
495499 assertionFailure ( " Unable to format \( String ( describing: quantity) ) \( unit) " )
496500 return Text ( " " )
497501 }
You can’t perform that action at this time.
0 commit comments