<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sahil Pathania on Medium]]></title>
        <description><![CDATA[Stories by Sahil Pathania on Medium]]></description>
        <link>https://medium.com/@sahilpathania1997?source=rss-16117b90d2e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*EFs09xJg_Ztn-DLcHru3bw.png</url>
            <title>Stories by Sahil Pathania on Medium</title>
            <link>https://medium.com/@sahilpathania1997?source=rss-16117b90d2e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 00:31:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sahilpathania1997/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Delegate Methods in TableView Using Swift-(Part 2)]]></title>
            <link>https://sahilpathania1997.medium.com/delegate-methods-in-tableview-using-swift-part-2-387968ba7443?source=rss-16117b90d2e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/387968ba7443</guid>
            <category><![CDATA[delegate]]></category>
            <category><![CDATA[delegates-in-tableview]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[tableviews]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Sahil Pathania]]></dc:creator>
            <pubDate>Sun, 13 Jun 2021 05:43:44 GMT</pubDate>
            <atom:updated>2021-06-13T05:43:44.574Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Delegate Methods in TableView Using Swift" src="https://cdn-images-1.medium.com/max/560/1*fiHitrk03WRi0RzUMfBIvw.png" /></figure><p>Hi Everyone! This blog will let you know about the delegate methods in the table view. If you don’t know much about table view and want to know more about it then you can check my other blog “<a href="https://medium.com/@sahilpathania1997/how-to-start-with-tableview-in-swift-bf273a8bbabe">How to Start with TableView in Swift</a>”.</p><p>There are many Delegates methods in swift. So, I divided it into two blogs half of the methods will cover in this blog, and the rest will be covered in my <a href="https://medium.com/@sahilpathania1997/delegate-methods-in-tableview-using-swift-part-1-661bbf0d5cc1">last blog</a>.</p><blockquote><strong>didHighlightRowAt<br></strong>func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath)</blockquote><p>Tells the delegate that the specified row was highlighted.</p><blockquote><strong>didUnhighlightRowAt<br></strong>func tableView(_ tableView: UITableView, didUnhighlightRowAt indexPath: IndexPath)</blockquote><p>Tells the delegate that the highlight was removed from the row at the specified index path.</p><blockquote><strong>willSelectRowAt<br></strong>func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -&gt; IndexPath?</blockquote><p>Tells the delegate a row is about to be selected.</p><blockquote><strong>willDeselectRowAt<br></strong>func tableView(_ tableView: UITableView, willDeselectRowAt indexPath: IndexPath) -&gt; IndexPath?</blockquote><p>Tells the delegate that a specified row is about to be deselected.</p><blockquote><strong>didSelectRowAt<br></strong>func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)</blockquote><p>Tells the delegate a row is selected.</p><blockquote><strong>didDeselectRowAt<br></strong>func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)</blockquote><p>Tells the delegate that the specified row is now deselected.</p><blockquote><strong>editingStyleForRowAt<br></strong>func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -&gt; UITableViewCell.EditingStyle</blockquote><p>Asks the delegate for the editing style of a row at a particular location in a table view.</p><blockquote><strong>titleForDeleteConfirmationButtonForRowAt<br></strong>func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -&gt; String?</blockquote><p>Changes the default title of the delete-confirmation button.</p><blockquote><strong>editActionsForRowAt<br></strong>func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -&gt; [UITableViewRowAction]?</blockquote><p>Asks the delegate for the actions to display in response to a swipe in the specified row.</p><blockquote><strong>leadingSwipeActionsConfigurationForRowAt<br></strong>func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -&gt; UISwipeActionsConfiguration?</blockquote><p>Returns the swipe actions to display on the leading edge of the row.</p><blockquote><strong>trailingSwipeActionsConfigurationForRowAt<br></strong>func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -&gt; UISwipeActionsConfiguration?</blockquote><p>Returns the swipe actions to display on the trailing edge of the row.</p><blockquote><strong>shouldIndentWhileEditingRowAt<br></strong>func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -&gt; Bool</blockquote><p>Asks the delegate whether the background of the specified row should be indented while the table view is in editing mode.</p><blockquote><strong>willBeginEditingRowAt<br></strong>func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath)</blockquote><p>Tells the delegate that the table view is about to go into editing mode.</p><blockquote><strong>didEndEditingRowAt<br></strong>func tableView(_ tableView: UITableView, didEndEditingRowAt indexPath: IndexPath?)</blockquote><p>Tells the delegate that the table view has left editing mode.</p><blockquote><strong>targetIndexPathForMoveFromRowAt<br></strong>func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -&gt; IndexPath</blockquote><p>Asks the delegate to return a new index path to retarget a proposed move of a row.</p><blockquote><strong>shouldBeginMultipleSelectionInteractionAt<br></strong>func tableView(_ tableView: UITableView, shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -&gt; Bool</blockquote><p>Asks the delegate whether the user can use a two-finger pan gesture to select multiple items in a table view.</p><blockquote><strong>didBeginMultipleSelectionInteractionAt<br></strong>func tableView(_ tableView: UITableView, didBeginMultipleSelectionInteractionAt indexPath: IndexPath)</blockquote><p>Tells the delegate when the user starts using a two-finger pan gesture to select multiple rows in a table view.</p><blockquote><strong>tableViewDidEndMultipleSelectionInteraction<br></strong>func tableViewDidEndMultipleSelectionInteraction(_ tableView: UITableView)</blockquote><p>Tells the delegate when the user stops using a two-finger pan gesture to select multiple rows in a table view.</p><p>Thankyou</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=387968ba7443" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Delegate Methods in TableView Using Swift-(Part 1)]]></title>
            <link>https://sahilpathania1997.medium.com/delegate-methods-in-tableview-using-swift-part-1-e3ee29b9ae61?source=rss-16117b90d2e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3ee29b9ae61</guid>
            <category><![CDATA[tableviews]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[delegate]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Sahil Pathania]]></dc:creator>
            <pubDate>Fri, 12 Jun 2020 04:45:07 GMT</pubDate>
            <atom:updated>2020-06-12T04:45:07.500Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Delegate Methods in TableView Using Swift" src="https://cdn-images-1.medium.com/max/560/1*jyHU3PyHfG2PMZAZWcKK-g.png" /></figure><p>Hi Everyone! This blog will let you know about the delegate methods in the table view. If you don’t know much about table view and want to know more about it then you can check my other blog “<a href="https://medium.com/@sahilpathania1997/how-to-start-with-tableview-in-swift-bf273a8bbabe">How to Start with TableView in Swift</a>”.</p><p>There are many Delegates methods in swift. So, I divided it into two blogs half of the methods will cover in this blog, and the rest will be covered in my next blog.</p><h3>What is Delegate in Tableview ?</h3><p>It deals with the way the table view appears. It contains methods that are used for displaying the table view cells. <em>UITableViewDelegate </em>needs to inherit to access the functions in it.</p><h3>Delegate Methods in UITableView</h3><ol><li><strong>willDisplay: </strong>This method gets called when the table view cell is going to display on the screen.<strong><br></strong><em>func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)</em></li><li><strong>willDisplayHeaderView: </strong>This method gets called when the header view of the section will be display.<strong><br></strong><em>func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int)</em></li><li><strong>willDisplayFooterView: </strong>This method gets called when the footer view of the section gets appear.<strong><br></strong><em>func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int)</em></li><li><strong>didEndDisplaying: </strong>This method gets called when the cell gets completely displayed on the table view.<strong><br></strong><em>func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath)</em></li><li><strong>didEndDisplayingHeaderView: </strong>This method gets called when the header view of section gets displayed on the table view.<strong><br></strong><em>func tableView(_ tableView: UITableView, didEndDisplayingHeaderView view: UIView, forSection section: Int)</em></li><li><strong>didEndDisplayingFooterView: </strong>This method gets called when the Footer view of section gets displayed on the table view.<strong><br></strong>func tableView(_ tableView: UITableView, didEndDisplayingFooterView view: UIView, forSection section: Int)</li><li><strong>heightForRowAt: </strong>This method gets called before the row gets created. You can set the height of the table view in this method. The return type of this method is <em>CGFoat</em>.<strong><br></strong><em>func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat</em></li><li><strong>heightForHeaderInSection</strong>: This method sets the height of header view for the current section. Return type of this method is <em>CGFloat.</em><br><em>func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -&gt; CGFloat</em></li><li><strong>heightForFooterInSection: </strong>This method sets the height of Footer view for the current section. Return type of this method is <em>CGFloat.</em><strong><br></strong>func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -&gt; CGFloat</li><li><strong>estimatedHeightForRowAt: </strong>This method can be used to set the height for custom cells. This method will use where the cell in the table view is of different height. You can give estimated height for the cell which can help to reduce the calculation time for the custom cell height and can provide a good user experience.<strong><br></strong><em>func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -&gt; CGFloat</em></li><li><strong>estimatedHeightForHeaderInSection: </strong>This method can be used set the height for custom header view in section.<strong><br></strong><em>func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -&gt; CGFloat</em></li><li><strong>estimatedHeightForFooterInSection: </strong>This method can be used set the height for custom footer view in section.<strong><br></strong><em>func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -&gt; CGFloat</em></li><li><strong>viewForHeaderInSection: </strong>This method is used to give the view for Footer in section. The return type for this method is <em>UIView.</em><strong><br></strong><em>func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView?</em></li><li><strong>viewForFooterInSection: </strong>This method is used to give the view for Footer in section. Return type for this method is <em>UIView.</em><strong><br></strong><em>func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -&gt; UIView?</em></li><li><strong>accessoryButtonTappedForRowWith : </strong>This method when the user clicks on the accessory type.<strong><br></strong><em>func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath)</em></li><li><strong>shouldHighlightRowAt : </strong>This method checks whether the row should be highlighted or not when the user clicks on the cell. The return type for this method is <em>Bool</em><strong>.<br></strong><em>func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -&gt; Bool</em></li></ol><h3>Conclusion</h3><p>These are some of the delegate methods in the table view. These methods can be very helpful for you while working on table views. You learn the rest of the methods in my next blog.<br>Please do share your valuable comment in the comment box given below and do write any topic which you think should be there in the above list.</p><p>Thank You</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3ee29b9ae61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Start with TableView in Swift]]></title>
            <link>https://sahilpathania1997.medium.com/how-to-start-with-tableview-in-swift-bf273a8bbabe?source=rss-16117b90d2e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf273a8bbabe</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[scroll]]></category>
            <category><![CDATA[table-view-cell]]></category>
            <category><![CDATA[tableviews]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Sahil Pathania]]></dc:creator>
            <pubDate>Sun, 17 May 2020 05:13:25 GMT</pubDate>
            <atom:updated>2020-05-17T05:13:25.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*zD-HlAm6R6zIX-09eNTcmA.png" /></figure><p>Hi everyone! Today I am going to show you step by step guide for “How to start with TableView in Swift?”. If you are new to swift and want to know that what are the various steps which you should follow in the initial phase of learning then you can go and check my blog “<a href="https://medium.com/@sahilpathania1997/beginners-guide-for-swift-programming-language-1f0ea49fdf8">Beginners Guide for Swift Programming Language</a>”. So without wasting any time let’s start with TableView in swift.</p><p><strong>What is TableView?</strong></p><p>TableView is an instance of UITableView which is itself a subclass of UIScrollView. A table view contains a list of TableView cells. A table view cell is an instance of UITableViewCell.</p><p><strong>Where to use Tableview?</strong></p><p>A table view is used to show the list of items. For example, if we look at the iPhone’s contacts list, settings page, or wheresoever the list of items is shown. Generally, we use table view if we want our page to be scrolled vertically for horizontal scrolling we can use CollectionView.</p><p><strong>Steps to add TableView using Swift:</strong></p><ol><li>Go to the <em>main.storyboard</em> and the View controller.</li><li>Now Drag Tableview from Library option to the View controller.</li></ol><figure><img alt="Use library in swift" src="https://cdn-images-1.medium.com/max/1024/1*YtX5fZvrPi3rL4ZjPMCkdw.png" /></figure><p>3. Add constraints according to the need.</p><p>4. Now Drag and Drop Table View Cell on to the TableView.</p><figure><img alt="Add cell in storyboard" src="https://cdn-images-1.medium.com/max/800/1*HXmfTtN6Qp4WePPWmWvNzQ.png" /></figure><p>5. Add a class for tale view cell from cocoa touch class having subclass UITableViewCell.</p><figure><img alt="Add class in swift" src="https://cdn-images-1.medium.com/max/1024/1*4Ei-VKNq0MjMtNbMtGR4Nw.png" /></figure><p>6. Now select TableView cell from the storyboard and give a class name to the cell in an identity inspector.</p><figure><img alt="Custom class on storyboard in swift" src="https://cdn-images-1.medium.com/max/522/1*r-ro0N-6p8ZNb67JkOa_tg.png" /></figure><p>7. Now Go to Attribute inspector and give a unique identifier to the cell.</p><figure><img alt="Add identifier in table view using swift" src="https://cdn-images-1.medium.com/max/516/1*6GTcYY2iwWMzOFxz0xJrdA.png" /></figure><p>8. Now add delegate and data source methods to the table view.</p><figure><img alt="Delegate and Data Source in swift" src="https://cdn-images-1.medium.com/max/560/1*sieD0CzKcB2ItDsTzmcQdQ.png" /></figure><blockquote><strong>Note: </strong>Datasource methods used to display the data on the table view cell and the Delegate methods used to give information about the cells.</blockquote><p>9. Give the outlet to the table view and connect it with the view controller.</p><p>Now try to run your code you will be able to see a blank list with an infinite number of cells.</p><figure><img alt="Table view in swift" src="https://cdn-images-1.medium.com/max/600/1*Nzj5YoxOgwnecKtFcKkN3w.png" /></figure><p>10. Now let’s come to the coding part. As you have already connected the delegate and data source with the table view now comes the part of using these properties. Inherit the <em>UITableViewDelegate</em> and <em>UITableViewDataSource</em> into the table view. Now you have access to all the delegate and data source methods. You can use those methods according to your need.</p><p>11. There are two methods which are mandatory to add below are these methods :</p><ul><li><em>tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int</em></li></ul><p>The above method defines the total number of rows that need to show in the table view.</p><ul><li><em>tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell</em></li></ul><p>The above method used to design your cell. This method called for each cell and the cell number is found by indexPath. Here you can use the <em>Label</em>, <em>textField</em>, <em>imageView</em>, <em>Button</em>, and other UI elements.</p><p>12. Create a cell using <em>the dequeueReusableCell </em>property of table view which helps to reuse the same cell multiple times and give a unique identifier as a parameter which we set in the Attribute inspector. Use “as” property to check whether it is matching with the class of cells.</p><p>13. Now you can give labels to the cell and add text into it. Below is the final code which shows the 20 cells with cell number.</p><figure><img alt="Cell creation in swift" src="https://cdn-images-1.medium.com/max/1024/1*R2Ib8-2ylKzjZo6eb_FeXQ.png" /></figure><p>Now run your application. It will look like the below-attached screenshot.</p><figure><img alt="How use table view in swift" src="https://cdn-images-1.medium.com/max/600/1*t1Q18Q825tiPtUUjkZDHHA.png" /></figure><p>That’s all you have successfully created an application using a table view.</p><h3><strong>Conclusion</strong></h3><p>A Tableview is an asset for UI development in the iOS application. It has many properties. You just need to google more about it and it’s all up to you how much effort you will put to get the best out of it.</p><p>Please do share your valuable comment in the comment box given below and do write any topic which you think should be there in the above list.</p><p>Thank You</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf273a8bbabe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>