Search code examples
iosviewdidloadviewwillappearviewdidappearuitableview

Mechanism about "did" and "will" and "should" method


I want to know generally when the methods including the key words stated in the topic were called.

For example:

– tableView:willSelectRowAtIndexPath:
– tableView:didSelectRowAtIndexPath:
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex

When will the willSelectRow method called? What does the method mean by including the key words "will" "did" and "should"

Similarly, there are viewDidAppear and viewWillAppear. It's obvious when the viewDidAppear method called. But the viewWillAppear one is quite beyond me.

Hope that someone could help;)


Solution

  • willSelectRow: Tells the delegate that a specified row is about to be selected.

    didSelectRow: Tells the delegate that the specified row is now selected.

    should: Returns whether the table view should allow selection of the specified row.

    It works the same way with viewDidAppear and viewWillAppear.

    viewDidAppear: the view has already appeared.

    viewWillAppear: the view is about to appear.

    You can learn more in the apple documentation.

    I hope that helped !