How to send a number and a String through a notification ...
let mynumber=1;
let mytext=\"mytext\";
NSNotificationCenter.defaultCenter().postNotificationName
Swift 4.0
First create a dictionary for multiple values.
let name = "Abhi"
let age = 21
let email = "abhi@xyz.com"
let myDict = [ "name": name, "age":age, "email":email]
// post myDict
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "post"), object: nil, userInfo: myDict)
Add observer in other ViewController
NotificationCenter.default.addObserver(self, selector: #selector(doThisWhenNotify(notification:)), name: NSNotification.Name(rawValue: "post"), object: nil)
func doThisWhenNotify(notification : NSNotification) {
let info = notification.userInfo
print("name : ",info["name"])
print("age : ",info["age"])
print("email : ",info["email"])
}