Skip to content

Commit

Permalink
Fix memory leak in navigation example (#2139)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksproger authored May 7, 2024
1 parent ce0d53a commit 121922b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions Apps/Examples/Examples/All Examples/NavigationSimulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ final class NavigationSimulator {
isStarted = true

viewport.transition(to: followPuckViewPortState) { _ in
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { timer in
if !self.routePointsToTravel.isEmpty {
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] timer in
guard let self else {
return timer.invalidate()
}

if !routePointsToTravel.isEmpty {
let nextPoint = self.routePointsToTravel.removeFirst()
self.currentLocation = nextPoint
currentLocation = nextPoint
} else {
// Journey completed.
timer.invalidate()
Expand Down
2 changes: 1 addition & 1 deletion Tests/ExamplesTests/TestableExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ObjectiveC.runtime
@testable import Examples
import MapboxMaps

class TestableExampleTests: XCTestCase {
final class TestableExampleTests: XCTestCase {
private var example: Example?
private weak var weakExampleViewController: UIViewController?
private weak var weakMapView: MapView?
Expand Down

0 comments on commit 121922b

Please sign in to comment.