NSNotificationCenter Tutorial
Uploader Comments (iElmoTutorials)
All Comments (9)
-
Thanks for the tutorial
Can an NSNotification send a data parameter to the listener?
-
@cuongchanluong Yep you can, just make sure of one important thing, well two actually. (And call reloadData if its a tableView)
If adding a new date etc id use presentModalViewController to pop a temp view onto the calendar viewcontroller, this gives you an easy dismiss feature plus looks cool.
Second is to make sure to [[NSNotificationCenter defaultCenter] removeObserver:self]; in the viewDidUnload because if your addObserver is in the viewDidLoad it'll keep adding observers.
-
@iElmoTutorials I'm trying to pass data between viewcontroller that's on a navigationviewcontroller stack (ie. in a calendar app how you add a date and select the start/end date on the next screen, and it gets set on the previous screen). One way is to do it with delegate but it's more hassle than with the notificationcenter.
-
@cuongchanluong Heya, glad you enjoyed it!
With regards to your question, are you talking about another navigation stack you want to send data to? NSNotification can send to anywhere anytime. But beware that adding observers uses memory AND if your classes(especially viewcontrollers) are constantly being re used then observers will keep getting added! So beware :)
That answer you question?
-
Great tutorial!
Can I use NSNotificationCenter to pass data between viewControllers in a navigationController stack? Thanks!
nice tutorial. Could I NSNotification to change an image of a UIIMageView from a button on another ViewController?
Nateddnd 1 week ago
@Nateddnd Hi glad you found it useful :)
To answer your question yes you can but what is your set up.NSNotificication is 12 kinds of awesome but updating the UI is more a delegate role.
PM me in more detail and we can talk
iElmoTutorials 1 week ago
Helped me quite a bit,Thanks
vinayutubeaccount 1 month ago
@vinayutubeaccount No problem, glad it helped
iElmoTutorials 1 month ago