I’d just like to verify an assumption I’m making. I’ve scoured through the chapter, and checked the developer docs. Generically speaking, is it accurate to say that a protocol’s required methods will be automatically executed upon instantiation of the object?
Specifically, I’m in chapter 10, on page 150, and there is no place in the code where I explicitly call the 2 required methods of UITableViewDataSource, yet they are magically being executed. Seems obvious, but I just want to someone to confirm that is what is really happening. So that in the future, if I look up a different class object and it conforms to a different protocol, I will know that if it lists methods as “required” that also implies they will be auto executed upon instantiation.
Are these “required” methods executed as a result of (or following) the init method?
So, essentially, what the protocol does, without direction from me, is execute 1 time the method tableView: numberOfRowsInSection. Uses that (integer) return value to loop thru the execution of tableView: cellForRowAtIndexPath, and by the way, converts the integer value into an NSIndexPath object while doing so. The tableView argument for both methods is available as a property from the class object.
That sound about right?