Re: Triggering UITableView's -didSelectRowAtIndexPath: delegate callback
Re: Triggering UITableView's -didSelectRowAtIndexPath: delegate callback
- Subject: Re: Triggering UITableView's -didSelectRowAtIndexPath: delegate callback
- From: Ben Kennedy <email@hidden>
- Date: Sat, 27 Feb 2016 14:59:05 -0800
> On 27 Feb 2016, at 11:17 am, Carl Hoefs <email@hidden> wrote:
>
> Yes, that works, thanks! I just thought there might be a "preferred" way to do it. I guess I was hoping for something like:
>
> [myTableView selectRowAtIndexPath:indexPath
> animated:YES
> scrollPosition:UITableViewScrollPositionMiddle
> triggersDelegateCallback:YES];
What gain would that afford you, though?
I believe that the table view API is designed this way to afford the programmer control and flexibility. Perhaps your didSelectRow:... implementation calls some private method to do the business logic, say -[self fireTheRockets]. In that case, you could simply call fireTheRockets directly here instead.
By contrast, the delegate API provides your code a means to act on external events (user input) brokered by the table view. Perhaps in such a case there is additional UI-related work not suitable for inclusion in fireTheRockets.
This decoupling enables you to separate these concerns.
-ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden