Redeem Now
Read More
Read now

Pass Data Back To The Previous View Controller Using NotificationCenter


With NotificationCenter you can broadcast data from one part of your app to another. In the iOS development process two entities will inevitably need to send and receive information and for this we here we will use NotificationCenter.

iOS notifications are a simple and powerful way to send data in a loosely coupled way. That is, the sender of notification doesn’t have to care about who (if anyone) receives the notification.

Here I’m using the NotificationCenter for sending data back from SecondViewController to FirstViewController.

First Step->

-> Registering for notification in first view controller

Second Step->

->  Notification Action in first view controller

Third Step->

-> Posting Notification from second view controller on back button action

Key Points:-

1-> NSNotification.Name(“Test”) is the struct identifying the specific notification by name.

2-> For the argument object, you can simply pass the object responsible for sending out notification

3-> userInfo is a payload which can be used to pass between sender and observer of notifications. It is a dictionary of type [AnyHashable : Any]

After Third Step you will get data back in first view controller  in “NotificationAct” Function.

OUTPUT:- “Webkul”


So pls follow the above step and And if you have any issue or suggestion you can leave your message in the comment section I will try to solve this.






. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again