Skip to content

Commit

Permalink
fix warning about wrong api usage
Browse files Browse the repository at this point in the history
'encodedOffset' is deprecated: encodedOffset has been deprecated as most common usage is incorrect. Use utf16Offset(in:) to achieve the same behavior.
  • Loading branch information
Patrick-Kladek committed Apr 15, 2024
1 parent a6278c6 commit e6ac126
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions MapboxCoreNavigationTests/DistanceFormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class DistanceFormatterTests: XCTestCase {
}

var effectiveQuantityRange = NSRange(location: NSNotFound, length: 0)
let quantityAttrs = checkedAttributedString.attributes(at: checkedQuantityRange.lowerBound.encodedOffset, effectiveRange: &effectiveQuantityRange)
let quantityAttrs = checkedAttributedString.attributes(at: checkedQuantityRange.lowerBound.utf16Offset(in: checkedAttributedString.string), effectiveRange: &effectiveQuantityRange)
XCTAssertEqual(quantityAttrs[NSAttributedString.Key.quantity] as? NSNumber, distance as NSNumber, "'\(quantity)' should have quantity \(distance)")
XCTAssertEqual(effectiveQuantityRange.length, quantity.count)

guard checkedQuantityRange.upperBound.encodedOffset < checkedAttributedString.length else {
guard checkedQuantityRange.upperBound.utf16Offset(in: checkedAttributedString.string) < checkedAttributedString.length else {
return
}
let unitAttrs = checkedAttributedString.attributes(at: checkedQuantityRange.upperBound.encodedOffset, effectiveRange: nil)
let unitAttrs = checkedAttributedString.attributes(at: checkedQuantityRange.upperBound.utf16Offset(in: checkedAttributedString.string), effectiveRange: nil)
XCTAssertNil(unitAttrs[NSAttributedString.Key.quantity], "Unit should not be emphasized like a quantity")
}

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ open class NavigationMapView: MLNMapView, UIGestureRecognizerDelegate {
}
}

// MARK: - Gesture Recognizers
// MARK: - Gesture Recognizers

/**
Fired when NavigationMapView detects a tap not handled elsewhere by other gesture recognizers.
Expand Down

0 comments on commit e6ac126

Please sign in to comment.