Ashbury
Ashbury

Reputation: 2346

Cannot infer contextual base in reference to member 'fractionLength'

I'm trying to follow this screencast on building an app for Apple Watch. I've updated Xcode to 13.3, but I'm getting an error that doesn't appear in the screencast.

Cannot infer contextual base in reference to member 'fractionLength'

Cannot infer contextual base in reference to member 'numeric'

Extra argument 'numberFormat' in call

Text(
    Measurement(
        value: 47,
        unit: UnitEnergy.kilocalories
    ).formatted(
        .measurement(
            width: .abbreviated,
            usage: .workout,
            numberFormat: .numeric(precision: .fractionLength(0))
            )
        )
    )

enter image description here

Upvotes: 0

Views: 658

Answers (1)

maybe things have changed. You could try this instead:

Text(Measurement( value: 47, unit: UnitEnergy.kilocalories)
        .formatted(
            .measurement(
                width: .abbreviated,
                usage: .workout,
                numberFormatStyle: .number.precision(.fractionLength(0))
            )
        )
)

Upvotes: 3

Related Questions