gpt4 book ai didi

ios - 如何在 RxSwift 中为去抖设置 RxTimeInterval?

转载 作者:搜寻专家 更新时间:2023-10-31 22:53:08 26 4
gpt4 key购买 nike

无法在 rxswift 中为去抖设置 Rxtimeinterval。我的代码如下。我收到此错误消息“无法将‘Double’类型的值转换为预期的参数类型‘RxTimeInterval’(又名‘DispatchTimeInterval’)”

searchBar
.rx.text // Observable property thanks to RxCocoa
.orEmpty // Make it non-optional
.debounce(0.5, scheduler: MainScheduler.instance) // Wait 0.5 for changes.
.distinctUntilChanged() // If they didn't occur, check if the new value is the same as old.
.filter { !$0.isEmpty }

错误信息:

"Cannot convert value of type 'Double' to expected argument type 'RxTimeInterval' (aka 'DispatchTimeInterval')"

最佳答案

searchBar
.rx.text // Observable property thanks to RxCocoa
.orEmpty // Make it non-optional
.debounce(.milliseconds(500), scheduler: MainScheduler.instance) // Wait 0.5 for changes.
.distinctUntilChanged() // If they didn't occur, check if the new value is the same as old.
.filter { !$0.isEmpty }

关于ios - 如何在 RxSwift 中为去抖设置 RxTimeInterval?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56506808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com