Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Richard Lu
Richard Lu
20,185 Points

TableView: CellAtForRowAtIndexPath

I was wondering who calls this method? is it the OS?

Richard Lu
Richard Lu
20,185 Points

I meant CellForRowAtIndexPath

1 Answer

Luke Schoen
Luke Schoen
3,317 Points

When you create a custom Objective-C class that inherits from UITableViewController the implementation file is pre-populated with instance methods which has the argument CellForRowAtIndexPath. If you hover your mouse over that argument and press the Option key on your keyboard and click the text with your mouse (OPT+Click) when the question mark appears it will show you information about it. Scroll down to 'Reference' and click UITableViewDataSource (a Protocol), which will take you to the Developer Documentation (same as going to the menu Help > Documentation and API Reference, and performing a search), then just scroll down to 'tableView:cellForRowAtIndexPath:', which explains all about it. Based on the documentation it appears the iOS calls UIKit framework, which in turn calls UITableViewController of your app, which must comply with UITableViewDataSource (protocol), so the protocol is also called, which are both of type NSObject, and this in turn calls an instance method tableView:cellForRowAtIndexPath that returns the cell contents of type UITableViewCell and which takes two arguments 'tableView' & 'indexPath'.

If anyone is able to correct my understand that would be greatly appreciated, as I'm learning too! :-)