0

我想为两个不同的来源发出两个不同的信号,但我在第 29 行遇到 Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)RxSwift/Event.swift崩溃:return "next(\(value))"

这是我的简化代码:

        let scheduler = TestScheduler(initialClock: 0)

        locationsFactory = TestableLocationsFactory()
        locationsFactory.didReceiveRegion = scheduler.createColdObservable([
        .next(100, regionEvents[0]),
        .next(200, regionEvents[1])
        ]).asObservable()

        locationsFactory.location = scheduler.createColdObservable([
        .next(120, locations[0]),
        .next(220, locations[1])
        ]).asObservable()

        let result = scheduler.createObserver(LocationChange.self)
        let dispatcher = BestAccuracyLocationsDispatcher(persistenceService: persistenceService, apiClient: api, locationManager: locationsFactory)

        subscription = dispatcher.dispatcher.subscribe(result)
        scheduler.start()

        let events = result.events

        XCTAssertEqual(events, [
            .next(120, LocationChange(location: locations[0], trigger: .updateLocations)),
            .next(220, LocationChange(location: locations[1], trigger: .updateLocations)),
        ])

当我删除locationsFactory.didReceiveRegionlocationsFactory.location它工作。

我可以创建两个不同的调度程序的 observables 吗?

4

1 回答 1

0

let region = CLRegion()我使用了一个抽象类的区域模拟。当我将其更改为:

let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: 5.555, longitude: 6.666), radius: Double(50), identifier: "xxx")

于 2020-05-26T10:55:39.730 回答