iOS Swift - Lists and Data DisplayWhich UITableViewDataSource method is used to provide a title for a section header?AtableView(_:cellForRowAt:)BtableView(_:titleForHeaderInSection:)CtableView(_:heightForRowAt:)DtableView(_:didSelectRowAt:)Check Answer
Step-by-Step SolutionSolution:Step 1: Recall UITableViewDataSource methods for headersThe method tableView(_:titleForHeaderInSection:) returns the text for the header of a section.Step 2: Differentiate from other methodsOther methods handle cells, row height, or selection, not headers.Final Answer:tableView(_:titleForHeaderInSection:) -> Option BQuick Check:Header title method = tableView(_:titleForHeaderInSection:) [OK]Quick Trick: Header titles use titleForHeaderInSection method [OK]Common Mistakes:Choosing cellForRowAt for headersConfusing heightForRowAt with header titlesSelecting didSelectRowAt which is for taps
Master "Lists and Data Display" in iOS Swift9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepUITryChallengeBuildRecallPublish
More iOS Swift Quizzes Animations - Transition effects - Quiz 15hard Concurrency - Await keyword - Quiz 4medium Concurrency - MainActor for UI updates - Quiz 5medium Concurrency - Async sequences - Quiz 12easy Lists and Data Display - Why lists present dynamic content - Quiz 13medium Navigation - Sheet and fullScreenCover - Quiz 15hard Navigation - Programmatic navigation - Quiz 4medium Navigation - NavigationLink - Quiz 6medium Navigation - TabView for tab navigation - Quiz 9hard Networking - Image loading from URL - Quiz 15hard