ios - DispatchQueue 在 Swift 中不起作用的问题
问题描述
我被这个问题困扰并尝试了各种方法,但没有运气。下面的代码用于几天前工作。但是,它现在不起作用。我尝试使用 Xcode 版本 11.1 并像魅力一样工作。有人可以让我知道可能是什么原因或解决方法吗?
问题是每当我输入一个键时,它都不会使用调度队列触发相应的方法。
当前的 Swift 版本:11.3
Code snippet:
init(
weatherFetcher: WeatherFetchable,
scheduler: DispatchQueue = DispatchQueue(label: "WeatherViewModel")
) {
self.weatherFetcher = weatherFetcher
_ = $city
.dropFirst(1)
.debounce(for: .seconds(0.5), scheduler: DispatchQueue.global())
.sink(receiveValue: fetchWeather(forCity:))
}
参考代码: https ://www.raywenderlich.com/4161005-mvvm-with-combine-tutorial-for-ios
解决方案
推荐阅读
- macos - 如何在终端中更改文件头
- raspberry-pi3 - Adafruit LPD8806m LED灯条防水吗?
- database - 为什么 Liquibase generateChangeLog 会生成一个空的 changelog 文件?
- javascript - 如何将外部 js 文件添加到我的布局页面
- javascript - 使用 Cloudflare Workers 将图像发送到 Telegram
- java - 如何成功导入包含所有依赖项的 AndroidX 包?
- c# - 无法使用 WordPressPCL 和 wp-api-jwt-auth 对 Linux 中托管在 Azure 中的 WordPress 进行身份验证
- performance - 了解 WebPageTest 瀑布
- python - 具有三向决胜局的 Python 高效排序算法
- java - 如何使所有实现特定接口的类都具有相同的构造函数?