Fixes problem with required error.

This commit is contained in:
Krunoslav Zaher 2016-02-13 23:49:41 +01:00
parent 300c44aced
commit 1c0475860a
2 changed files with 22 additions and 2 deletions

View File

@ -49,10 +49,10 @@ extension CLLocationManager {
/**
Reactive wrapper for `delegate` message.
*/
public var rx_didFinishDeferredUpdatesWithError: Observable<NSError> {
public var rx_didFinishDeferredUpdatesWithError: Observable<NSError?> {
return rx_delegate.observe("locationManager:didFinishDeferredUpdatesWithError:")
.map { a in
return try castOrThrow(NSError.self, a[1])
return try castOptionalOrThrow(NSError.self, a[1])
}
}
#endif

View File

@ -84,6 +84,26 @@ extension CLLocationManagerTests {
XCTAssertTrue(completed)
}
func testDidFinishDeferredUpdatesWithError_noError() {
var completed = false
var error: NSError?
autoreleasepool {
let manager = CLLocationManager()
_ = manager.rx_didFinishDeferredUpdatesWithError.subscribe(onNext: { e in
error = e
}, onCompleted: {
completed = true
})
manager.delegate!.locationManager!(manager, didFinishDeferredUpdatesWithError: nil)
}
XCTAssertEqual(error, nil)
XCTAssertTrue(completed)
}
#endif
#if os(iOS)