【问题标题】:Convert to Swift 3 - Notification Centre dispatch queue转换为 Swift 3 - 通知中心调度队列
【发布时间】:2017-01-29 02:17:47
【问题描述】:

正在努力将其转换为 Swift 3。您能帮忙吗?

dispatch_async(dispatch_get_main_queue()) { () -> Void in
    self.delegate.locationDidUpdateToLocation(self.currentLocation!)
    NSNotificationCenter.defaultCenter().postNotificationName(kLocationDidChangeNotification, object: self, userInfo: userInfo as [NSObject : AnyObject])
}

非常感谢!

【问题讨论】:

    标签: ios swift2 swift3


    【解决方案1】:

    我不确定那个委托方法是什么,但它的其余部分看起来像这样:

    DispatchQueue.main.async {
    
        NotificationCenter.default.post(name: notification_name, object: self, userInfo:userInfo )
    
    }
    

    我不确定kLocationDidChangeNotification

    【讨论】:

    • 有效!必须承认对通知中心的所有更改感到很困惑,那里有很多版本,似乎没有一个是正确的!
    猜你喜欢
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多