The NSNotification requires the Second View to be loaded into memory. If you use an tab application the second view is not loaded into memory until you click on the page two.
I will need to try my tab control video and see if the second view is loaded into memory
@davepamn Tabbed applications load all views from the start, see my tabbar tutorial, in the delegate all view controllers in the tabs_array are loaded before the app
@davepamn No, it only sends a notification to a listener and the listener starts an operation. Why would you want to do that anyway? Just pass the property:
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 :)
@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 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.
The NSNotification requires the Second View to be loaded into memory. If you use an tab application the second view is not loaded into memory until you click on the page two.
I will need to try my tab control video and see if the second view is loaded into memory
davepamn 1 day ago
@davepamn Tabbed applications load all views from the start, see my tabbar tutorial, in the delegate all view controllers in the tabs_array are loaded before the app
iElmoTutorials 1 day ago
Thanks for the tutorial
Can an NSNotification send a data parameter to the listener?
davepamn 1 day ago
@davepamn No, it only sends a notification to a listener and the listener starts an operation. Why would you want to do that anyway? Just pass the property:
NSString *str = "Hello"
[self performPrint:str]
-(void) perfortmPrint:(NSString *) str{}
iElmoTutorials 1 day ago
nice tutorial. Could I NSNotification to change an image of a UIIMageView from a button on another ViewController?
Nateddnd 2 weeks 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 2 weeks ago
Helped me quite a bit,Thanks
vinayutubeaccount 1 month ago
@vinayutubeaccount No problem, glad it helped
iElmoTutorials 1 month ago
Great tutorial!
Can I use NSNotificationCenter to pass data between viewControllers in a navigationController stack? Thanks!
cuongchanluong 2 months ago
@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?
iElmoTutorials 2 months ago
@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 2 months ago
@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 2 months ago