In this challenge, you'll use filtering operators to create a utility that looks up phone numbers in a sample data set.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4743-beginning-rxswift/lessons/16
In this challenge, you'll use filtering operators to create a utility that looks up phone numbers in a sample data set.
For anybody using RxSwift 5: toArray()
does now convert an Observable into a Single.
So we have to use the onSuccess
handler instead of the onNext
handler in the .subscribe
method
//..
.toArray()
.subscribe( onSuccess: { numbers in
let phone = phoneNumber(from: numbers )
if let contact = contacts[phone] {
print("Dailing \(contact) (\(phone))...")
} else {
print("Contact Not Found")
}
}
//..
@thorben Thank you for sharing the solution - much appreciated! :]