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 }
}
网友评论