<?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 Shashank Şingla on Medium]]></title>
        <description><![CDATA[Stories by Shashank Şingla on Medium]]></description>
        <link>https://medium.com/@shashankingla?source=rss-632452009929------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3_2IXp_uhgWuTtZ4.</url>
            <title>Stories by Shashank Şingla on Medium</title>
            <link>https://medium.com/@shashankingla?source=rss-632452009929------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 17:36:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shashankingla/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[A Comprehensive Guide to Git Cherry-Pick]]></title>
            <link>https://medium.com/@shashankingla/a-comprehensive-guide-to-git-cherry-pick-389351b2afd4?source=rss-632452009929------2</link>
            <guid isPermaLink="false">https://medium.com/p/389351b2afd4</guid>
            <dc:creator><![CDATA[Shashank Şingla]]></dc:creator>
            <pubDate>Wed, 29 May 2024 07:56:43 GMT</pubDate>
            <atom:updated>2024-05-29T07:56:43.332Z</atom:updated>
            <content:encoded><![CDATA[<p>Version control is a crucial aspect of modern software development, enabling teams to manage changes, collaborate efficiently, and maintain a history of their codebase. Git, a popular version control system, offers a variety of commands to facilitate these tasks. One such command is git cherry-pick, which allows you to apply specific commits from one branch into another. In this blog post, we’ll explore what cherry-picking is, why it’s useful, and how to use it effectively in your iOS Swift projects.</p><h3>What is Git Cherry-Pick?</h3><p>Cherry-picking in Git is the process of selecting specific commits from one branch and applying them to another. This is particularly useful when you want to backport bug fixes, bring in specific features, or isolate and merge certain changes without integrating the entire branch.</p><h3>When to Use Cherry-Pick</h3><ul><li>Bug Fixes: You have a bug fix in a feature branch that you want to apply to the master branch.</li><li>Feature Migration: A specific feature implemented in one branch needs to be added to another branch without merging all other changes.</li><li>Selective Updates: You want to apply only certain changes from a series of commits.</li></ul><h3>Cherry-Pick Example in iOS Swift Development</h3><h3>Scenario</h3><p>Imagine you are working on an iOS project with multiple branches: main, feature/login, and bugfix/crash-on-launch. A critical bug fix has been made in the bugfix/crash-on-launch branch, and you need to apply this fix to the main branch without merging all other changes from the bugfix branch.</p><h3>Steps to Cherry-Pick</h3><ul><li>Identify the Commit Hash</li></ul><p>First, identify the commit hash you want to cherry-pick. You can find this by checking the commit history of the bugfix/crash-on-launch branch.</p><pre>git checkout bugfix/crash-on-launch<br>git log --oneline</pre><p>You will see a list of commits. Copy the hash of the commit you want to cherry-pick.</p><ul><li><em>Switch to the Target Branch</em></li></ul><p>Switch to the main branch where you want to apply the commit.</p><pre>git checkout main</pre><ul><li><em>Cherry-Pick the Commit</em></li></ul><p>Use the git cherry-pick command followed by the commit hash.</p><pre>git cherry-pick &lt;commit-hash&gt;</pre><p>Git will apply the changes from the specified commit to your current branch (main in this case).</p><ul><li><em>Resolve Conflicts (If Any)</em></li></ul><p>Sometimes, cherry-picking may result in conflicts if the same code sections have been modified differently in the target branch. Git will notify you of conflicts, and you need to resolve them manually.</p><pre>git status<br># Edit the conflicting files to resolve the conflicts<br>git add &lt;resolved-file&gt;<br>git cherry-pick --continue</pre><ul><li><em>Verify the Changes</em></li></ul><p>After successfully cherry-picking the commit, verify that the changes have been applied correctly.</p><pre>git log --oneline</pre><ul><li><em>Push the Changes</em></li></ul><p>Finally, push the changes to the remote repository.</p><pre>git push origin main</pre><h3>Conclusion</h3><p>Git cherry-pick is a powerful tool for selectively applying commits across branches, making it easier to manage specific changes without merging entire branches. By following the steps outlined in this blog post, you can effectively use cherry-pick to enhance your iOS Swift development workflow. Whether you are backporting bug fixes or migrating features, cherry-picking offers a flexible solution to maintain a clean and organized codebase.</p><p>Feel free to share your thoughts and experiences with cherry-picking in the comments below. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=389351b2afd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Dispatch Barrier in Swift: A Comprehensive Guide]]></title>
            <link>https://medium.com/@shashankingla/understanding-dispatch-barrier-in-swift-a-comprehensive-guide-3d885625977d?source=rss-632452009929------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d885625977d</guid>
            <dc:creator><![CDATA[Shashank Şingla]]></dc:creator>
            <pubDate>Wed, 29 May 2024 07:32:39 GMT</pubDate>
            <atom:updated>2024-05-29T07:32:39.093Z</atom:updated>
            <content:encoded><![CDATA[<p>Concurrency is a fundamental aspect of modern software development, enabling applications to perform multiple tasks simultaneously. In Swift, the Grand Central Dispatch (GCD) framework provides powerful tools for managing concurrent tasks, and one of its lesser-known but highly useful features is the dispatch barrier. In this blog post, we’ll explore what a dispatch barrier is, how it works, and when to use it in your Swift projects.</p><h3>What is a Dispatch Barrier?</h3><p>A dispatch barrier is a type of task that acts as a synchronization point in a concurrent dispatch queue. It ensures that the specified task is the only one executing on that queue at any given time. This allows you to safely update shared resources without risking data corruption due to simultaneous access from multiple threads.</p><h3>Key Characteristics of Dispatch Barriers:</h3><ul><li>Exclusive Execution: When a barrier task is executing, no other tasks can run concurrently on the same queue.</li><li>Order Enforcement: Tasks submitted before the barrier will complete before the barrier executes, and tasks submitted after the barrier will wait until the barrier finishes.</li></ul><h3>How to Use Dispatch Barrier</h3><p>Using dispatch barriers in Swift is straightforward. You need to use a concurrent queue and submit the barrier task using the dispatch_barrier_async or dispatch_barrier_sync functions.</p><h3>Example: Updating a Shared Resource</h3><p>Let’s consider a scenario where multiple threads need to read from and write to a shared resource, such as an array. Here’s how you can use a dispatch barrier to ensure safe updates:</p><pre>import Foundation<br><br>class SafeArray&lt;T&gt; {<br>    private var array: [T] = []<br>    private let queue = DispatchQueue(label: &quot;com.example.safeArray&quot;, attributes: .concurrent)<br><br>    func append(_ item: T) {<br>        queue.async(flags: .barrier) {<br>            self.array.append(item)<br>        }<br>    }<br><br>    func getItems() -&gt; [T] {<br>        var items: [T] = []<br>        queue.sync {<br>            items = self.array<br>        }<br>        return items<br>    }<br>}<br><br>let safeArray = SafeArray&lt;Int&gt;()<br>let group = DispatchGroup()<br><br>for i in 1...5 {<br>    group.enter()<br>    DispatchQueue.global().async {<br>        safeArray.append(i)<br>        group.leave()<br>    }<br>}<br><br>group.wait()<br>print(safeArray.getItems())</pre><p>In this example:</p><ul><li>We create a SafeArray class that manages an array with thread-safe operations.</li><li>The append method uses async(flags: .barrier) to ensure that adding an item to the array happens exclusively, blocking other tasks on the same queue.</li><li>The getItems method uses sync to read the array&#39;s contents safely.</li></ul><h3>When to Use Dispatch Barriers</h3><p>Dispatch barriers are particularly useful when you need to perform both read and write operations on a shared resource within a concurrent environment. Here are some common scenarios:</p><ul><li>Data Structures: Ensuring thread-safe access to data structures like arrays, dictionaries, or sets.</li><li>Database Operations: Performing read and write operations on a database without risking data corruption.</li><li>Configuration Changes: Updating shared configuration settings that multiple parts of an application read from.</li></ul><h3>Best Practices</h3><ul><li>Use Concurrent Queues: Dispatch barriers only make sense on concurrent queues. Using them on serial queues negates their benefits since tasks are already executed one at a time.</li><li>Minimize Synchronous Barriers: Prefer dispatch_barrier_async over dispatch_barrier_sync to avoid blocking the current thread, which can lead to performance bottlenecks.</li><li>Combine with Other Synchronization Tools: In complex scenarios, consider combining dispatch barriers with other synchronization mechanisms like semaphores or locks to achieve the desired level of concurrency control.</li></ul><h3>Conclusion</h3><p>Dispatch barriers are a powerful feature in Swift’s concurrency toolkit, enabling developers to manage shared resources safely and efficiently. By understanding how and when to use them, you can write more robust and concurrent applications. Whether you’re working on a simple data structure or a complex system, dispatch barriers can help you maintain data integrity and avoid common pitfalls of concurrent programming.</p><p>Feel free to share your thoughts and experiences with dispatch barriers in the comments below. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d885625977d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Custom Drawing with Canvas in SwiftUI]]></title>
            <link>https://medium.com/@shashankingla/mastering-custom-drawing-with-canvas-in-swiftui-8c97aabdf9c6?source=rss-632452009929------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c97aabdf9c6</guid>
            <category><![CDATA[canvas]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Shashank Şingla]]></dc:creator>
            <pubDate>Mon, 20 May 2024 16:29:24 GMT</pubDate>
            <atom:updated>2024-05-20T16:29:24.451Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>SwiftUI has transformed how we build user interfaces, making it easier to create beautiful and responsive apps. With the introduction of the Canvas view in iOS 15, Apple has given developers a powerful tool for custom drawing. Whether you&#39;re creating custom graphics, interactive visualizations, or unique UI elements, the Canvas view provides a flexible and performant way to bring your creative ideas to life.</p><p>In this article, we’ll explore the basics of Canvas, demonstrate how to draw various shapes and images, and show you how to create dynamic, interactive drawings.</p><h3>Getting Started with Canvas</h3><h3>What is Canvas?</h3><p>The Canvas view is a new addition to SwiftUI that allows you to draw custom graphics using Swift&#39;s built-in drawing capabilities. It leverages the power of Core Graphics under the hood, providing a performant way to create custom drawings.</p><h3>Setting Up Your Environment</h3><p>To get started, make sure you have Xcode 13 or later installed, as Canvas requires iOS 15, macOS 12, tvOS 15, or watchOS 8.</p><h3>Creating a Basic Canvas</h3><p>Let’s start with a simple example to draw a circle on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9hWrjfIbVbucw0s0iDntsQ.png" /></figure><h3>Explanation</h3><ol><li>Canvas: The main view for custom drawing. It provides a drawing context and the size of the canvas.</li><li>Path: Used to define shapes. Here, we create a circle path.</li><li>context.stroke: Strokes the path with a specified color and line width.</li></ol><h3>Drawing Shapes</h3><p>The Canvas view allows you to draw a variety of shapes. Let&#39;s explore how to draw rectangles, lines, and polygons.</p><h3>Drawing a Rectangle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oRSE7LUH03bYSm7qy6L2w.png" /></figure><h3>Drawing Lines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRu9mWlJFzXOzIIASdJpPQ.png" /></figure><h3>Drawing a Polygon</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rbYRqQOeGbFtKDJsbHwNNQ.png" /></figure><h3>Adding Images and Text</h3><p>The Canvas view can also be used to draw images and text, making it versatile for various custom drawing needs.</p><h3>Drawing an Image</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TvqEC6lwar0sTpYoYgkpCQ.png" /></figure><h3>Drawing Text</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yIWAVzNeMqOhWg0TipD1sQ.png" /></figure><h3>Creating Interactive Drawings</h3><p>One of the exciting aspects of using Canvas is the ability to create interactive drawings. Let&#39;s create a simple example where the user can draw on the canvas using touch.</p><h3>Interactive Drawing Example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-8IupAPDKQjQcXab_sFXVQ.png" /></figure><h3>Explanation</h3><ol><li>@State Properties: paths stores all completed paths, while currentPath holds the path being drawn.</li><li>Canvas: Draws all paths and the current path.</li><li>DragGesture: Captures user input for drawing. onChanged updates the current path, and onEnded saves the path and resets for a new one.</li></ol><h3>Conclusion</h3><p>The Canvas view in SwiftUI opens up a world of possibilities for custom drawing and interactive graphics. Whether you’re drawing simple shapes, adding text and images, or creating dynamic user interactions, Canvas provides a flexible and powerful toolset.</p><p>By mastering the basics and exploring more complex examples, you can leverage Canvas to create unique and engaging experiences in your apps. Happy drawing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c97aabdf9c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>