Added: 2 months ago
From: iElmoTutorials
Views: 572
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (12)

Sign In or Sign Up now to post a comment!
  • 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

  • Thanks for the tutorial

    Can an NSNotification send a data parameter to the listener?

  • @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{}

  • nice tutorial. Could I NSNotification to change an image of a UIIMageView from a button on another ViewController?

  • @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

  • Helped me quite a bit,Thanks

  • @vinayutubeaccount No problem, glad it helped

  • Great tutorial!

    Can I use NSNotificationCenter to pass data between viewControllers in a navigationController stack? Thanks!

  • @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 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.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more