Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Notification Center use for broadcasting singles or notifying the methods at the same time. It uses the Observer pattern to inform registered observers when a notification comes in, using a central dispatcher called NotificationCenter.
Before we get started, some quick notes:
NotificationCenter
NSNotificationCenter
Let’s create a project to pass and receive data one controller to second controller from Notification Center.
2. In first controllerView , we add or remove Observer in:
This is the notification registration process for receiving. Based on the key NotificationCenter can observe.
The addObserver(_:selector:name:object:) function has 5 parameters:
addObserver(_:selector:name:object:)
NotificationCenter.default
Observer
Object
Bool, String, Dictionary, Array, Int
3. Now write functions you want to call when a notification is observed.
function has one parameter, which is a Notification object. you can use userInfo to send some data with the notification.
userInfo
4. Every notification has a name of type Notification.Name.
2. Now, add Notification Post in both button action.
This will call the notification method from any place and changed the label and image view according to key. It will identify based on key the observer. You can also pass data with this post Notification.
For other blogs Please click here
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.
Stathis Plakidas
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.