receive notificationcenter data in swift
let imageDataDict:[String: UIImage] = ["image": image]
// post a notification
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "notificationName"), object: nil, userInfo: imageDataDict)
// `default` is now a property, not a method call
// Register to receive notification in your class
NotificationCenter.default.addObserver(self, selector: #selector(self.showSpinningWheel(_:)), name: NSNotification.Name(rawValue: "notificationName"), object: nil)
// handle notification
@objc func showSpinningWheel(_ notification: NSNotification) {
print(notification.userInfo ?? "")
if let dict = notification.userInfo as NSDictionary? {
if let id = dict["image"] as? UIImage{
// do something with your image
}
}
}
Also in Swift:
- get icloud doc swift
- type String and int swift addition
- check if nan swift
- swift create uinavigationcontroller programmatically
- swift image button blue
- number of characters in a string swift
- remove and element from array firebase swift 5
- how to make box shadow swift
- switches xcode
- xcode disable a button
- ios rounded button
- find range of string swift
- swift bring something to front of view
- convert secondsfrom1970 to date swift
- swift add navigation bar
- how to screen record swift stackoverflow
- swift dictionary get key from valye
- swift save data to file
- urlencode string swift
- swift file size from url
- swift how to animate constraint change
- swift how to call a function
- how to add two right bar button item xcode
- swift get device screen size