美文网首页
iOS Swift 数据传递相关

iOS Swift 数据传递相关

作者: A_rcher34 | 来源:发表于2020-06-28 15:45 被阅读0次

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 }
}

相关文章

网友评论

      本文标题:iOS Swift 数据传递相关

      本文链接:https://www.haomeiwen.com/subject/zprwfktx.html