iOS Swift 数据传递相关

2020-06-28  本文已影响0人  A_rcher34

1 通知传递(Notification)

// 发送通知(例:通过通知传递参数fullName和email)
NotificationCenter.default.post(name: NSNotification.Name.init("将要发送的通知名字 String"), object: nil, userInfo: ["fullName": fullName!, "email": email!])
// 接收通知
NotificationCenter.default.addObserver(self, selector: #selector(dp_f_signinByGoogleNoti(_:)), name: NSNotification.Name.init("将要发送的通知名字 String"), object: nil)
// 处理通知
@objc private func dp_f_signinByGoogleNoti(_ noti: Notification) {
    guard let fullName = noti.userInfo?["fullName"] as? String else { return }
    guard let email = noti.userInfo?["email"] as? String else { return }
}
上一篇 下一篇

猜你喜欢

热点阅读