<?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 Nidhi Suhagiya on Medium]]></title>
        <description><![CDATA[Stories by Nidhi Suhagiya on Medium]]></description>
        <link>https://medium.com/@suhagiya.nidhi99?source=rss-1380695d0470------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aYJ35678Ex5CwDap.jpg</url>
            <title>Stories by Nidhi Suhagiya on Medium</title>
            <link>https://medium.com/@suhagiya.nidhi99?source=rss-1380695d0470------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 06:35:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suhagiya.nidhi99/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[Meet GCD: The Traffic Controller of iOS Apps]]></title>
            <link>https://medium.com/@suhagiya.nidhi99/meet-gcd-the-traffic-controller-of-ios-apps-5166cfde348b?source=rss-1380695d0470------2</link>
            <guid isPermaLink="false">https://medium.com/p/5166cfde348b</guid>
            <dc:creator><![CDATA[Nidhi Suhagiya]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 19:39:05 GMT</pubDate>
            <atom:updated>2025-06-21T16:20:32.772Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern iPhones are super smart because they have <strong>more than one brain (called cores)</strong> inside. This means your phone can <strong>do many things at the same time</strong>. For example, your app can download a big file in the background while still letting you tap buttons and play with it without freezing.</p><p>Apple gives us <strong>two ways to make this multitasking work</strong>:<br> 👉 <strong>Grand Central Dispatch (GCD)</strong> and <strong>NSOperation</strong>.</p><p>In this story, we’re going to talk about <strong>GCD</strong>, which helps your app do different jobs at the same time. <strong>Grand Central Dispatch (GCD) </strong>is a technology developed by Apple for managing concurrent operations in iOS, macOS, and watchOS.</p><p>Let’s imagine you are <strong>playing a game</strong> on your iPad. While you’re <strong>playing</strong>, the game is showing cool animations 🎮. At the same time, it is also <strong>loading new levels</strong> in the background 📦. So, the iPad is doing <strong>two things at once</strong>:</p><ol><li>Showing you the game smoothly.</li><li>Loading new stuff without making you wait.</li></ol><p>👉 <strong>GCD</strong> is like a <strong>smart helper</strong> that tells the iPad:</p><ul><li>“Do this job now.”</li><li>“Do this other job later.”</li><li>“You can do this quietly in the background while the player is busy.”</li></ul><h4>🛠️ How Does GCD Work?</h4><p>GCD uses something called <strong>queues</strong>:</p><ul><li><strong>Main Queue:</strong> The one that handles the user interface (what you see and touch).</li><li><strong>Background Queues:</strong> Quiet places where your app can do other work without bothering you.</li></ul><h4>Example:</h4><p>Let’s say:</p><ul><li>You want to <strong>download a picture</strong> from the internet.</li><li>While waiting, you want to <strong>keep playing</strong> your game.</li></ul><p>Here’s a simple Swift example:</p><pre>import Foundation<br><br>// This is a background job (like loading a picture)<br>DispatchQueue.global().async {<br>    print(&quot;Downloading picture... 🚀&quot;)<br><br>    // Pretend we are waiting 3 seconds (downloading)<br>    sleep(3)<br><br>    print(&quot;Finished downloading! 🎉&quot;)<br><br>    // Go back to the main screen to show the picture<br>    DispatchQueue.main.async {<br>        print(&quot;Show the picture on screen! 🖼️&quot;)<br>    }<br>}<br><br>print(&quot;Keep playing the game! 🎮&quot;)</pre><h4>🎯 What’s Happening:</h4><ul><li>DispatchQueue.global().async {} → Do this <strong>in the background</strong>.</li><li>DispatchQueue.main.async {} → Come back to the <strong>main screen</strong> to update the game.</li><li>async → Means <strong>do it later, don’t wait, keep going!</strong></li></ul><h4>🧁 Summary:</h4><p>GCD helps <strong>iOS do many things at the same time</strong>. It makes apps <strong>faster</strong> and <strong>smoother</strong>. It’s like telling your iPad:<br> 👉 “You can load this quietly in the background while I keep playing!”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5166cfde348b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Collections: Array vs. Set — When to Use Each]]></title>
            <link>https://medium.com/@suhagiya.nidhi99/swift-collections-array-vs-set-when-to-use-each-67102a3d6365?source=rss-1380695d0470------2</link>
            <guid isPermaLink="false">https://medium.com/p/67102a3d6365</guid>
            <dc:creator><![CDATA[Nidhi Suhagiya]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 19:36:14 GMT</pubDate>
            <atom:updated>2023-09-03T19:36:14.513Z</atom:updated>
            <content:encoded><![CDATA[<h3>Swift Collections: Array vs. Set — When to Use Each</h3><p>When working with collections of data in Swift, you often have to decide which data structure to use. Two common choices are arrays and sets. Each has its own strengths and weaknesses, and the choice between them depends on the specific requirements of your project. In this blog post, we’ll explore the differences between arrays and sets in Swift to help you make an informed decision.</p><p><strong>Arrays</strong></p><p>An array is an ordered collection of elements of the same type. Here are some key characteristics of arrays in Swift:</p><ol><li>Elements in an array are stored in a specific order, and you can access them by their index.</li><li>Arrays can contain duplicate elements.</li><li>Accessing elements by index in an array is fast, with O(1) time complexity.</li></ol><pre>var fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;]</pre><p><strong>Sets</strong></p><p>A set is an unordered collection of unique elements of the same type. Here are some key characteristics of sets in Swift:</p><ol><li>It contains all unique elements. It automatically remove duplicate elements.</li><li>Sets do not maintain the order of elements. If element order is not important for your task, this can be more efficient than arrays.</li><li>Checking for the presence of an element in a set is fast, with O(1) time complexity.</li></ol><pre>var fruits: Set&lt;String&gt; = [&quot;Apple&quot;, &quot;Banana&quot;, &quot;Orange&quot;]</pre><p>In simple terms, think of an array as a list of items where you care about the order and may have duplicates, while a set is like a bag of unique items where order doesn’t matter, and each item is distinct. Choose the one that best fits your needs based on these characteristics when working with collections in Swift.</p><p>I hope this article was helpful to you. Happy learning! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67102a3d6365" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[String interpolation]]></title>
            <link>https://medium.com/@suhagiya.nidhi99/string-interpolation-37b2615eb645?source=rss-1380695d0470------2</link>
            <guid isPermaLink="false">https://medium.com/p/37b2615eb645</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Nidhi Suhagiya]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 19:13:43 GMT</pubDate>
            <atom:updated>2023-07-14T19:15:16.549Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>what is String Interpolation?</strong></p><p>In short terms, it is simplifying Variable Incorporation in Strings.</p><p>Let me explain in detail, string interpolation is a way to combine or insert variables or values into a string to create a new string. It’s like a fancy way of mixing text and variables together.</p><p>Let’s say you have a variable chocolateName with the value “Nestle”. With string interpolation, you can create a new string that includes the value of the variable. Instead of manually concatenating the variable with the string using the “+” symbol, string interpolation provides a simpler and more readable syntax.</p><p>In Swift, you can use placeholders inside a string, typically denoted by a special symbol like “\()” [Add a <strong>forward slash</strong> followed by an <strong>open parenthesis</strong> and then your variable name and at the end add a <strong>closing parenthesis</strong>]. This placeholder is then replaced with the actual value of the variable when the string is evaluated.</p><pre>let chocolateName = &quot;Nestle&quot;<br>let totalChocolates = 5<br>let message = &quot;I have total of \(totalChocolates) \(chocolateName) chocolates.&quot;<br>print(message)<br><br>//I have total of 5 Nestle chocolates.</pre><p>As you can see, the placeholder&#39;s <strong>totalChocolates</strong> and <strong>chocolateName</strong> are replaced with the values of these variables within the string.</p><p>String interpolation makes it easier to build dynamic strings by incorporating variables, making the code more concise and readable. It helps avoid excessive string concatenation and makes the code easier to maintain.</p><p>Hurray! So go ahead, leverage the power of string interpolation in your programming endeavours and unlock a more efficient and elegant way to handle string manipulation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37b2615eb645" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mutable and Immutable Variables in Swift: Understanding Changeability]]></title>
            <link>https://medium.com/@suhagiya.nidhi99/mutable-and-immutable-variables-in-swift-understanding-changeability-b1def28fc3dd?source=rss-1380695d0470------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1def28fc3dd</guid>
            <dc:creator><![CDATA[Nidhi Suhagiya]]></dc:creator>
            <pubDate>Sun, 21 May 2023 19:39:13 GMT</pubDate>
            <atom:updated>2023-05-21T19:39:13.087Z</atom:updated>
            <content:encoded><![CDATA[<p>In Swift, variables and constants can be classified as either mutable or immutable based on whether their values can be changed or not after they are assigned.</p><p>Let’s understand it in easy language:</p><ol><li><strong>Mutable:</strong> Think of a mutable variable like a container that you can change or modify. It’s like having a box where you can put something in, take it out, or replace it with something else whenever you want.</li></ol><p>Similarly, if you have a mutable variable, you can update its value or assign a new value to it whenever you need to. Mutable variables are declared using the var keyword. Once assigned, their values can be modified or reassigned. You can change the value of a mutable variable throughout the execution of your program. For example:</p><pre>var age = 25<br>age = 26 // Valid: Changing the value of a mutable variable</pre><p><strong>2. Immutable:</strong> On the other hand, an immutable variable is like a box that you seal shut once you put something inside it. Once you seal the box, you cannot change what’s inside it. It remains the same throughout.</p><p>In the case of an immutable variable, once you assign a value to it, you cannot modify or reassign that value later on. Constants declared using the let keyword are immutable. Immutable variables represent values that remain constant throughout the execution of the program. For example:</p><pre>let name = &quot;John&quot;<br>name = &quot;Mike&quot; // Invalid: Cannot change the value of an immutable constant<br></pre><p>The choice between mutable and immutable variables depends on whether you need the flexibility to modify the value later on or if you want to ensure that the value remains constant and cannot be changed accidentally.</p><p><strong>Note: </strong>Immutable variables are often preferred when you want to guarantee the integrity of data or optimize performance in certain scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1def28fc3dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Change app icon dynamically]]></title>
            <link>https://medium.com/@suhagiya.nidhi99/change-app-icon-dynamically-2905a97fda93?source=rss-1380695d0470------2</link>
            <guid isPermaLink="false">https://medium.com/p/2905a97fda93</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[app-icon]]></category>
            <dc:creator><![CDATA[Nidhi Suhagiya]]></dc:creator>
            <pubDate>Sun, 20 Mar 2022 02:06:39 GMT</pubDate>
            <atom:updated>2022-03-20T02:06:39.051Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0tYWbqazItITqOSMNNQfQ.jpeg" /></figure><p>From iOS 10.3+ you are able to change the app icon dynamically or based on the selection from the provided icons in app. For this, apple provides a method called <strong>setAlternateIconName(_:completionHandler:).</strong></p><p>But, you can change it only if the value of the <strong>supportsAlternateIcons </strong>property is true.</p><p><strong>Declaration:</strong></p><blockquote>func setAlternateIconName(_ alternateIconName: <a href="https://developer.apple.com/documentation/swift/string">String</a>?, completionHandler: ((<a href="https://developer.apple.com/documentation/swift/error">Error</a>?) -&gt; <a href="https://developer.apple.com/documentation/swift/void">Void</a>)? = nil)</blockquote><p><strong>Here,</strong></p><p><strong>alternateIconName: </strong>As the name suggest, you have to pass the name of the alternate icons which is used to display instead of the main app icon. Pass nil if you want to display primary icon of the app.</p><p><strong>completionHandler: </strong>The code inside this closure will be executed after the completion of the method call. After attempting to change the app’s icon, the system reports the result by calling completionHandler. If it fails to change the icon, then it will return an error parameter. The value of the error parameter will be nil on success otherwise it contains an error object and the value of the alternateIconName property remains unchanged.</p><p>Let’s dive into the implementation:</p><p>You can achieve this in two ways.</p><ol><li>Specify the names of additional icon assets available to your app using the “Alternate App Icon Sets” in the build setting.</li></ol><p>Xcode uses these setting to generate the entries for <a href="https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleicons/cfbundleprimaryicon">CFBundlePrimaryIcon</a> and <a href="https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleicons/cfbundlealternateicons">CFBundleAlternateIcons</a> under the top-level key <a href="https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleicons">CFBundleIcons</a>.</p><p><strong>Steps:</strong></p><ul><li>Add additional AppIcons in assets</li><li>Go to the build settings of your target app</li><li>Search alternate app icon Sets and Add alternate icons names to “Alternate App Icon Sets”</li></ul><p>2. Another way is you have to add <strong>CFBundlePrimaryIcon </strong>and <strong>CFBundleIcons </strong>keys in your Info.plist file.</p><p>You can add AppIcons either in your assets or in seperate folder under your workspace.</p><blockquote>If you add Alternate AppIcons under assets, then set value of <strong>IncludeAllApp Icon Assets </strong>attribute to YES.</blockquote><p>Source code to add inside info.plist is as below:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjtc0S4VKLX4I3HFAARVrA.png" /></figure><p><strong>Or property list of Info.plist will looks like this:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bf-RwBETdvN7VhEup5Ttmw.png" /></figure><p>After adding appIcons and doing required configuration, inside your view controller, check if app supports alternate icons or not using supportsAlternateIcons as shown below:</p><pre>if UIApplication.shared.supportsAlternateIcons {<br>   // set a new app icon<br>}</pre><p>Then Set alternate icons using setAlternateIconName() method as shown below:</p><pre>UIApplication.shared.setAlternateIconName(“AppIcon-2”) { error <strong>in<br>    </strong>print(“Error to set alternate icons:- \(error?.localizedDescription)”)<br>}</pre><p>That’s it. You are ready to go.</p><p>You can check code here:- <a href="https://github.com/NidhiSuhagiya/DynamicAppIcon">https://github.com/NidhiSuhagiya/DynamicAppIcon</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2905a97fda93" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>