Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Chapter 11: can anyone just point out what is this useful for? and why IbAction instead of void?

hi, i just wanna know why did we use:

self.clearsSelectionOnViewWillAppear = NO;

in the BIDLanguageListController.m file. I pressed Alt + on it and i did actaully understood what is it, but in the example project i didn't know what's the difference between putting it's value as a YES or a NO. putting both have the same effect or in other words nothing changes. My theory is that when i click on a president then a language then change to another president, the language selection will switch to english as a default if the value was YES. please correct me if i'm wrong. 

second question, why did we use IBAction instead of void in the code? i know that IBAction is actually a void but why was it chosen? what was the author's intentions ? Thank you!


  • edited February 2013
    By default UITableViewController will clear the selection of the UITableView it owns when the view appears. In most iPhone apps this makes sense since when for example stepping back from a detail view deselecting the row in the list we are coming back to, that opened the closed detail view, makes sense.

    Admittedly for the BIDLanguageListController this makes no difference since the instance is recreated every time the view popover is presented, our mistake, the language feature is intentionally incomplete for the sake of brevity. It would make a difference if you rewrote the toggleLanguagePopover method inBIDDetailViewController.m like this:

            BIDLanguageListController *languageListController =

            [[BIDLanguageListController allocinit];

            languageListController.detailViewController = self;

            static BIDLanguageListController *languageListController = nil;

            static dispatch_once_t onceToken;

            dispatch_once(&onceToken, ^{

                languageListController = [[BIDLanguageListController allocinit];

                languageListController.detailViewController = self;


    The language feature is still not complete, but one step closer. 

    I recommend looking at BIDMasterViewController for a better example.

    In our iPad app this is not the behavior we want since we want to retain the selection the master list of Presidents to always reflect the president being viewed in the detail view. You can see this when using the app in portrait mode and node/show the master list. Fist select a president, hide the master list and bring it up again by tapping thePresidents button, notice that the selected president is still highlighted.

    Now go back to BIDMasterViewController.m and comment outself.clearsSelectionOnViewWillAppear = NO; and run the app again. Select a president, hide the masters list, and bring the list back again. Notice that the selected president is no longer highlighted in the list.

    // Fredrik
Sign In or Register to comment.