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

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
How to implement notificationcenter in Swift using notificationcenter swift notificationcenter swift swiftui notificationcenter notificationcenter with send value in swift how to pass data using notificationcenter in swift notificationcenter swift ios 13 with data notifications in swift local notification immediate in swift local notification in swift how to set local notification in swift passing data with notificationcenter Notificationcenter in swift que hace el notification center swift extra argument in call swift NotificationCenter nsnotificationcenter object swift tutorial iosnotificationcenter class how to access ns events swift ios implement notificatio center get notification center notifications swift NotificationCenter sample in swift notification observer in swift 5 swift notification center custom notifications swift notification center custom notification app will terminate notification swift NotificationCenter.default.addObserver get user id data passing using notification center swift notification center swift 5 pass data NSNotificationCenter.default.post() ge value from a method usin notification in swift pass data with notificationcenter swift button pass data with notificationcenter swift pass data using notificationcenter swift NotificationCenter.default.post how to send data in notification how to pass data into the notification Notification center observer swift 4 notification with data swift 4 pass data using notfications swift swift notifier listen NotificationCenter.default.addObserver with object notification center example how to pass data through notification pass data throught notification center in swift Swift 5 Notication center passing user data notification center swift passing userInfo in notification swift swift add data to notification swift send data with notification pass data through observer notification swift 4 swift notificationcenter how to pass data in notification center in swift where to place NotificationCenter.default.addObserver in swift where to place NotificationCenter addObserver in swift using notification center to pass values swift notification center Swift pass object with notification swift get userinfo notification center swift send data using notifiactioncenter swift swift post notification with data how to use notificationcenter to transfer data swift receive notificationcenter data in swift
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source