ios - NSNotificationCenter 语法
问题描述
我有这行代码,但它是 swift 的旧版本,我听说语法已经改变。代码写在下面。在 Xcode 11 中讲述它的当前语法会很有帮助。
我也对这些变化进行了很多研究,但找不到任何东西
DispatchQueue.main.async 中的代码是较旧的代码,我需要更新的语法
语法(从旧版本开始)如下所示:
DispatchQueue.main.async {
NSNotificationCenter.defaultCenter().postNotificationName( The parameters of the code )
}
解决方案
您必须导入NotificationCenter
,它将是:
DispatchQueue.main.async {
NotificationCenter.default.post(name: Name Here, object: nil or Any)
}
推荐阅读
- vue.js - 超出 :per-page 值时,buefy b-table 不会自动移至下一页?
- android - Android SQLite 按天分组
- math - 使用 min max 函数和属性的操作
- mysql - mysql CREATE 触发器不起作用,创建触发器时出错
- git - 远程分支在本地可用吗?
- arraylist - 将不同维度数组的列表转换为元组
- javascript - 如何在带有电子的 vue.js 中使用两个 @click $emit 函数
- applescript - 在 AppleScript 中实现字符串插值的简单方法
- javascript - ReferenceError: VUE_APP_CONFIG 未定义 Jest 单元测试失败
- javascript - 子组件在本地存储被清除之前重新渲染