5

Give an explanation about difference between UITableView delegate methods:

didDeselectRowAtIndexPath:

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath  

and

willSelectRowAtIndexPath

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
iNoob
  • 3,364
  • 2
  • 26
  • 33

2 Answers2

7

willSelectRowAtIndexPath message is sent to the UITableView Delegate after the user lifts their finger from a touch of a particular row and before didSelectRowAtIndexPath.

willSelectRowAtIndexPath allows you to either confirm that the particular row can be selected, by returning the indexPath, or select a different row by providing an alternate indexPath.

Good luck

T

Maulik
  • 19,348
  • 14
  • 82
  • 137
timthetoolman
  • 4,613
  • 1
  • 22
  • 22
6

the code written in

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath(NSIndexPath*)indexPath 

method is run after selected the row and the code is written in

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath(NSIndexPath*)indexPath 

run just before the row selected.

they are same as

- (void)viewDidAppear:(BOOL)animated and - (void)viewWillAppear:(BOOL)animated

let me know if you have any confusion now.

TheTiger
  • 13,264
  • 3
  • 57
  • 82