<?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 Maadhav Mohan on Medium]]></title>
        <description><![CDATA[Stories by Maadhav Mohan on Medium]]></description>
        <link>https://medium.com/@maadhavmohan?source=rss-15c371b11d0f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tbf3i7wBJDY9RaNR-M5Z6g.jpeg</url>
            <title>Stories by Maadhav Mohan on Medium</title>
            <link>https://medium.com/@maadhavmohan?source=rss-15c371b11d0f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:01:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maadhavmohan/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[DispatchWorkItem And DispatchSemaphore]]></title>
            <link>https://medium.com/@maadhavmohan/dispatchworkitem-and-dispatchsemaphore-c9bf6a8231e?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9bf6a8231e</guid>
            <category><![CDATA[dispatchworkitem]]></category>
            <category><![CDATA[dispatchsemaphore]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Tue, 08 Nov 2022 17:28:18 GMT</pubDate>
            <atom:updated>2022-11-08T17:28:18.095Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a45cecfc4e8dd16f158e350919790bf/href">https://medium.com/media/8a45cecfc4e8dd16f158e350919790bf/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9bf6a8231e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part2: Asynchronous Tests and Expectations in iOS swift]]></title>
            <link>https://medium.com/@maadhavmohan/asynchronous-tests-and-expectations-in-ios-swift-eaaf0c4734f3?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaaf0c4734f3</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[asynchronous-tests]]></category>
            <category><![CDATA[tests-and-expectations]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 13:47:32 GMT</pubDate>
            <atom:updated>2022-11-15T10:19:54.620Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>A brief note on asynchronous code:</strong></p><ol><li>If any piece of code runs on different thread or dispatch queue, in a delegate method, or in callback, function marked with async, it will be called as asynchronous function.</li><li>And asynchronous code doesn’t execute directly within the current flow of code.</li></ol><p><strong>Testing</strong> <strong>asynchronous code:</strong></p><p>XCTest provides two approaches for testing asynchronous code.</p><ol><li>Swift codes that use async and await for concurrency, for these, we add our test methods async or async throws to test them asynchronously.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*l2eyUP_biw2haJiwcKehug.png" /><figcaption><strong>Asynchronous Type1 code example</strong></figcaption></figure><p>2. For any other types of asynchronous code,</p><p>Within our test method we create one or more expectations objects before testing actual code<em>. And these objects will be used by </em>XCTest to handle waiting of the test method.</p><p>Once all expectations are fulfilled( expectations fulfillment will be notified by calling fulfill() method), XCTest will stop waiting for the test method and start executing further pieces of code.</p><p>We call wait(:, :) function to make test method wait until all the expectations are fulfilled or specified time in the wait() function expires.</p><p>When we can’t use Swift async, use expectations to test asynchronous code. For example, using expectations when there isn’t a Swift async alternative available or <strong>when your asynchronous code runs in:</strong></p><ul><li>Objective-C</li><li><strong>An asynchronous block in a dispatch queue</strong></li><li>A delegate method</li><li><strong>An asynchronous callback, closure, or completion block</strong></li><li>A Future or Promise in Swift Combine</li><li>A situation where it needs to complete within a specific amount of time</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6WVUk0lqxLHYhctTISXHQ.png" /><figcaption>Asynchronous Type 2 Example</figcaption></figure><blockquote>Refer to Apple Official Documentation below for more detailed explanation .</blockquote><p><a href="https://developer.apple.com/documentation/xctest/asynchronous_tests_and_expectations">Asynchronous Tests and Expectations | Apple Developer Documentation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaaf0c4734f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part1: Unit Testing in Swift iOS(XCTest Framework)]]></title>
            <link>https://medium.com/@maadhavmohan/unit-testing-in-xcode-xctest-framework-4c4b3971b8e8?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c4b3971b8e8</guid>
            <category><![CDATA[xctestcase]]></category>
            <category><![CDATA[xctest]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[unit-testing-video]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Mon, 31 Oct 2022 09:16:32 GMT</pubDate>
            <atom:updated>2022-11-03T14:24:49.933Z</atom:updated>
            <content:encoded><![CDATA[<h3>Defining Test Cases and Test Methods:</h3><blockquote>Add test cases and test methods to a test target to confirm that the target performs as expected.</blockquote><p>Create test cases by subclassing <a href="https://developer.apple.com/documentation/xctest/xctestcase">XCTestCase</a> class. And we write test methods and group them inside these test cases.</p><p>To add tests to our project:</p><ul><li>Create a new subclass of XCTestCase within a test target.</li><li>Add one or more test methods to the test case.</li><li>Add one or more test assertions to each test method.</li></ul><p>A test method is an instance method on a XCTestCase subclass, with no parameters, no return value.</p><p>“testMethods” begins with the lowercase word <em>test</em>. Because of this keyword “test”, test methods are automatically detected by the XCTest framework in Xcode.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*8ggPA-GC6dT4grNnsAyZHQ.png" /></figure><p>Here we are creating TableValidationTests class which is a subclass of XCTestCase with a single test method testEmptyTableRowAndColumnCount(). This test method creates a new instance of a class called Tableand checks that tablerowCount and columnCount properties are both equal to 0 after initialization.</p><blockquote>Note: Test case and test method names are used in Xcode’s test navigator and integration reports to group and identify tests.</blockquote><h3>Asserting Test Conditions</h3><ol><li>We can assert(or <em>check</em>) conditions inside our test methods to make sure that our code is behaving as expected.</li><li>We use the XCTAssert family functions to check for different value types such as Boolean conditions, nil or non-nil values, expected values, and thrown errors.</li></ol><h3>XCTestCase:</h3><p><strong>The primary class for defining test cases, test methods, and performance tests.</strong></p><ol><li>Test case is a subclass of XCTest class.</li><li>Test case includes a group of related test methods and optional setUp method and tearDown method that runs before and after all the test methods respectively.</li><li>setUp() class method will be called before any other test methods in the test case.</li><li>tearDown() class method will be called after all the test methods got executed in the test case. It will be the last method to be executed in the test case.</li></ol><p>XCTestCase conforms to <a href="https://developer.apple.com/documentation/xctest/xctactivity">XCTActivity</a>, so we can simplify complex tests by organizing them into activities, and attach output to tests for later analysis.</p><p><strong>Note:</strong> Refer to this link for more info about <a href="https://developer.apple.com/documentation/xctest/activities_and_attachments/grouping_tests_into_substeps_with_activities"><strong>Grouping tests into Substeps and activities.</strong></a></p><p><strong>More about test methods :</strong></p><ol><li>We can create tests for asynchronous operations using expectations. For more information, see Testing Asynchronous Operations with Expectations. <a href="https://developer.apple.com/documentation/xctest/asynchronous_tests_and_expectations">Link</a></li><li>We can create tests to measure performance for specific blocks of code using the methods in the Measuring Performance section. <a href="https://developer.apple.com/documentation/xcode/improving-your-app-s-performance">Tap here for more info</a></li></ol><h3>Set Up and Tear Down State</h3><blockquote><strong><em>We use set Up to prepare initial state for all the test methods before any test method runs, and similarly we use Tear Down to clean up resources after all tests complete executing.</em></strong></blockquote><p><strong>SetUp and Tear Down state for TestCase Class:</strong></p><p>For a state that’s common to all the test methods in our test class and that doesn’t need a reset for each test method, use the <a href="https://developer.apple.com/documentation/xctest/xctestcase/1496262-setup">setUp()</a> class method on <a href="https://developer.apple.com/documentation/xctest/xctestcase">XCTestCase</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*PGG6YEr99xbr8XDszg0pyQ.png" /><figcaption>Fig1</figcaption></figure><p>XCTest runs setUp() once before the test class begins.</p><p>If you need to clean up temporary files or capture any data that you want to analyze after the test class is complete, use the <a href="https://developer.apple.com/documentation/xctest/xctestcase/1496280-teardown">tearDown()</a> class method on XCTestCase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*L-ZLhojB_aTuxwgAlkxs1A.png" /><figcaption>Fig2</figcaption></figure><p><strong>Order of execution of setUp and TearDown instance methods for every test method:</strong></p><p>When we run testcase , XCTest will first call the method setUp() of XCTestCase(It is a class method) before any test methods. And we use this method to set up state which is common to all the test methods of that testcase class.</p><p><strong>Order of execution of instance methods in every test method:</strong></p><ol><li><strong>XCTest runs the setup methods once before each test method starts, in the order of</strong></li></ol><p>1. setUp() async throws,</p><p>2. setUpWithError(),</p><p>3. setUp()</p><p><em>We use these instance methods to prepare state that we need for each </em><strong><em>test method</em></strong><em>.</em></p><p><strong>2. XCTest runs the test method.</strong></p><p><strong>3. Then XCTest will run teardown instance methods in “last in first out” order.</strong></p><p>teardown instance methods order of execution for every test method:</p><ol><li>tearDown()</li><li>tearDownWithError()</li><li>tearDown() async throws</li></ol><p><em>We use these instance methods to tear down state after each </em><strong><em>test method</em></strong><em>.</em></p><p>When XCTest finishes running all the test methods and test case class, it calls XCTestCase tearDown() class method.</p><p>We use this tearDown() class method to tear down the state which is common for all the testMethods of testcase class.</p><blockquote>Note 1:</blockquote><blockquote>There is a lot difference in setUp and tearDown class methods and</blockquote><blockquote>setUp and tearDown instance methods.</blockquote><blockquote>Note 2:</blockquote><blockquote>We can include assertions inside the setUp() async throws,setUpWithError(), setUp() and tearDown(), tearDownWithError(), tearDown() async throws <em>instance methods</em> as these are called before and after every test method respectively, XCTest will consider these as part of test method.</blockquote><blockquote>But, we cant include assertions inside setUp() and tearDown() class methods.</blockquote><p>Official video about how to write unit test cases:</p><p><a href="https://developer.apple.com/videos/play/wwdc2019/413/">Testing in Xcode - WWDC19 - Videos - Apple Developer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c4b3971b8e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High Order Functions in Swift iOS(reduce, reduce(into: ), map, compactMap, flatMap, filter)]]></title>
            <link>https://medium.com/@maadhavmohan/high-order-functions-in-swift-ios-reduce-reduce-into-map-compactmap-flatmap-filter-bbcc951b2606?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbcc951b2606</guid>
            <category><![CDATA[compactmap]]></category>
            <category><![CDATA[reduce]]></category>
            <category><![CDATA[high-order-functions]]></category>
            <category><![CDATA[filters]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 11:49:40 GMT</pubDate>
            <atom:updated>2022-11-17T06:45:46.726Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>High Order functions used for collections like Array, Dictionary and Set are:</strong></h4><ol><li><strong>reduce() :</strong></li></ol><p>Use the reduce(_:_:) method to produce a single value from the elements of an entire sequence. For example, we can use this method on an array of numbers to find their sum or product.</p><blockquote><strong>Syntax: </strong>func reduce&lt;Result&gt;( _ initialResult: Result, _ nextPartialResult: (Result, Self.Element) throws -&gt; Result ) rethrows -&gt; Result</blockquote><p>Example1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*So6HBwk7oAoIOPBGNHkthQ.png" /></figure><p>When numbers.reduce(_:_:) is called, the following steps occur:</p><ol><li>The nextPartialResult closure is called with initialResult—0 in this case—and the first element of numbers, returning the sum: 1.</li><li>The closure is called again repeatedly with the previous call’s return value and each element of the sequence.</li><li>When the sequence is exhausted, the last value returned from the closure is returned to the caller.</li></ol><p>If the sequence has no elements, nextPartialResult is never executed and initialResult is the result of the call to reduce(_:_:).</p><p>Example2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ZcyRwVPDeA4cGw1zlK-ZQ.png" /></figure><p><strong>2. reduce(into: ):</strong></p><blockquote><strong>Syntax:</strong> func reduce&lt;Result&gt;( into initialResult: Result, _ updateAccumulatingResult: (inout Result, Self.Element) throws -&gt; () ) rethrows -&gt; Result</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*prvdJ_rQyp-0r2BQIfkxxQ.png" /></figure><p><strong>3. map() :</strong></p><p>This function returns an array which will be computed and returned by applying the same closure operation to every single element of the array.</p><blockquote>syntax: func map&lt;T&gt;(_ transform: (Self.Element) throws -&gt; T) rethrows -&gt; [T]</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEAypb5Fior54V6HKyG4CA.png" /></figure><p><strong>4. flatMap() :</strong></p><p>Returns an array containing the concatenated results generated by calling the closure on every element of the sequence.</p><p><em>Syntax 1: func flatMap&lt;SegmentOfResult&gt;(_ transform: (Self.Element) throws -&gt; SegmentOfResult) rethrows -&gt; [SegmentOfResult.Element] where SegmentOfResult : </em><a href="https://developer.apple.com/documentation/swift/sequence"><em>Sequence</em></a></p><p><em>syntax 2: func flatMap&lt;ElementOfResult&gt;(_ transform: (Self.Element) throws -&gt; ElementOfResult?) rethrows -&gt; [ElementOfResult]</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*DWptw-eK-4IbWwzKbise8g.png" /><figcaption>fig1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*IGfCG1JkDggzXS0zmwROow.png" /><figcaption>fig2</figcaption></figure><p><strong>5. compactMap() :</strong></p><ol><li>Returns an array of non nil values</li><li>If any array contains nil values then it will remove those entries in the resulting array. //input: [1,nil, 2, nil, 4] Output: [1, 2, 4]</li><li>It is similar to map() function. Map returns array containing nil values whereas compactMap() does not return array containing nil values.</li><li>Here transform closure return value will be nil whereas the map’s non-nil.</li></ol><blockquote>Syntax: func compactMap&lt;ElementOfResult&gt;(_ transform: (Self.Element) throws -&gt; ElementOfResult?) rethrows -&gt; [ElementOfResult]</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1puy-xx0XXk8ZVAFvHH2w.png" /></figure><p><strong>6. filter() :</strong></p><p>We use filter over a collection to iterate each element one by one and return elements which are satisfied the provided condition in the closure.</p><blockquote>Syntax: func filter(_ isIncluded: (Self.Element) throws -&gt; <a href="https://developer.apple.com/documentation/swift/bool">Bool</a>) rethrows -&gt; [Self.Element]</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*Y-gjZ3GPGq6DyKHQRnoQ8w.png" /><figcaption>ex1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*bcRk1NL6uRpyKsAYQtjyPA.png" /><figcaption>ex2</figcaption></figure><p><strong>For more info about these functions refer to:</strong></p><ol><li><a href="https://developer.apple.com/documentation/swift/array/map(_:)-87c4d">https://developer.apple.com/documentation/swift/array/map(_:)-87c4d</a></li><li><a href="https://abhimuralidharan.medium.com/higher-order-functions-in-swift-filter-map-reduce-flatmap-1837646a63e8">https://abhimuralidharan.medium.com/higher-order-functions-in-swift-filter-map-reduce-flatmap-1837646a63e8</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbcc951b2606" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Navigation Controller Programmatically]]></title>
            <link>https://medium.com/@maadhavmohan/creating-navigation-controller-programmatically-bfff5dede7bd?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfff5dede7bd</guid>
            <category><![CDATA[navigation-controller]]></category>
            <category><![CDATA[programmatic-approach]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 14:42:00 GMT</pubDate>
            <atom:updated>2022-10-21T14:42:00.950Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c84aa501471a0e34779e72d6aa6f04b/href">https://medium.com/media/5c84aa501471a0e34779e72d6aa6f04b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfff5dede7bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frame VS Bounds in iOS]]></title>
            <link>https://medium.com/@maadhavmohan/frame-vs-bounds-in-ios-4547ba241101?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4547ba241101</guid>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 14:19:42 GMT</pubDate>
            <atom:updated>2022-12-23T07:37:20.395Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Frame:</strong> The frame of the rectangle, which describes the view’s location and size in its superview’s coordinate system.</p><p><strong>Bounds:</strong> The bounds of the rectangle, which describes the view’s location and size in its own coordinate system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4547ba241101" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part1:- iOS Interview Questions.]]></title>
            <link>https://medium.com/@maadhavmohan/ios-interview-questions-77e116ad506?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/77e116ad506</guid>
            <category><![CDATA[ios-interview]]></category>
            <category><![CDATA[ios-interview-question]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 11:56:46 GMT</pubDate>
            <atom:updated>2022-11-17T10:55:54.649Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>If you have received a call while using your app in what state your app will be transitioned?</strong></li></ol><p>Ans: To Foreground Inactive / ResignActive state</p><p><strong>2. Say if i continue the call for 40 minutes or 1 hour will your app be preserved in the memory or will be terminated?</strong></p><p>Ans: Yes, it will be preserved in the memory. Because if app is removed from memory(when it gets terminated) that means app is suspended and we will have to relaunch it.</p><p>So while you are on call all the events like Notifications will be stored back to APNS by iOS and as soon as your app comes in Active state it will start receiving events.</p><p><strong>3. What check you will make before initiating a download process when user taps the download button.</strong></p><p>Ans: I check my internet connectivity and space for downloading.</p><p><strong>4. What process will happen when user taps app icon before the willFinishLaunching of app delegate is called?</strong></p><p>Ans:</p><p>1- it will lookout for non-running application processes and low level structures and also it prepares the launching sequence from starting to end.</p><p>2- main() function will be calling UIApplicationMain which will create the UIApplication() instance for us.</p><p>3- Now UIKit will help you to call defualt storyboard which you have defined in Info.plist. If not used and designed UI programmatically then skip the step.</p><p>4- Now UIKit will be calling willFinishLaunch.</p><p>For more information about App Launch Sequence please have a look at:</p><p><a href="https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app/about_the_app_launch_sequence">About the app launch sequence | Apple Developer Documentation</a></p><p><strong>5. Why cant we use sync on main thread and also rectify the below code.</strong></p><p>DispatchQueue.main.sync {</p><p>debugPrint(“hello”)</p><p>}</p><p>error — error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).</p><p>Ans: When we haven&#39;t specified any thread, then code will start executing on the Main thread.</p><p>Async says, continue whatever you’re doing, once done execute this block.</p><p>But, Sync says, stop the main thread execution and execute this block.</p><p>Its like you have blocked execution of main thread and expecting your other code to run on it. This is not possible. Because it’s like,you have tied up a man to pole tightly and expecting him to run from there.Thats why app will crash.</p><p><strong>6. Difference between struct and classes in terms of memory management. When should we use structs vs classes give examples.</strong></p><p>Ans:</p><ol><li>As structs are value type and their reference count will be zero ARC will easily deallocate memory of structs and it will take care of everything(And Structs will be stored in Stack).</li><li>But as Classes are reference types we should give concentration on not creating “Strong Reference Cycle” between two reference types.</li><li>We should use classes when we want to maintain and persist changes reflect in all the references that are referring to the same instance.</li></ol><p><strong>7. When is required to capture self inside your closure and when should it be [self] vs [weak self], do we ALWAYS need to use weak/unowned keyword before self in capture list, or is it applicable in certain scenarios?? Provide examples.</strong></p><p>Ans:</p><p>closure() inside a struct -&gt; self</p><p>closure() inside a class -&gt; [weak / unowned self] to remove strong reference cycle.</p><p>Making a reference type property Weak/Unowned will make creating no strong reference to instance referred by this property.</p><p><strong>8. does enum contain stored properties ?</strong></p><p>Ans: No, but they contain a stored property appended with keyword static.</p><p><strong>9. How Can i avoid retaincycle without using weak and unowned?</strong></p><p>Ans: No we can’t. Apple recommends to use these to remove reference cycle. However, we can manually set nil to objects carefully or in the deinit block we can set nil very carefully. Because this action should not make our app gets crash.</p><p><strong>10. Predict the output of the following code and reason out why</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*FgMvIh4pvy9ohM7igqx2pg.png" /></figure><p>Ans: Output is: Bike</p><p>Because in the above example, vehicle is a value type and setting vehicle = “Car” won&#39;t reflect as it’s a value type. If vehicle was a reference type then the output would have been “Car” only.</p><blockquote>Note: Each item in a capture list is a pairing of the weak or unowned keyword with a reference to a class instance (such as self) or a variable initialized with some value (such as delegate = self.delegate). These pairings are written within a pair of square braces, separated by commas.</blockquote><p>For more info regarding the above example:</p><p><a href="https://marinofelipe.github.io/swift/swift-capture-list/">Swift capture lists: Reference vs Value properties</a></p><p><strong>11. Even though NSString is a reference type why the output is so?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*9KSZGIIMT9IDZNH1MzGVeg.png" /></figure><p><strong>12. Difference between NSLayoutConstraint and NSLayoutAnchor.</strong></p><p>Ans: Both are used to apply constraints to any UI. But new approach which is Anchor, is very easy to implement and read.</p><p>But NSLayoutConstraint gives more options for dealing with complex constraints.</p><p><strong>Note:</strong> We can get rid of writing .isActive = true (which we use for anchor) by putting them inside NSLayoutConstraint.activate([]) array.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*IQJT27vNT6tsavq-7tsdog.png" /><figcaption>fig1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*kORBq6LsZDjLufuuw4SVuA.png" /><figcaption>fig2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*h19fBFKi235fHZgjO6Qdyw.png" /><figcaption>fig3</figcaption></figure><p><strong>For More Info:</strong></p><p><a href="https://stackoverflow.com/questions/66941442/difference-between-using-nslayoutconstraints-initializer-compared-to-anchors-for">Difference between using NSLayoutConstraints initializer compared to Anchors for setting constraints</a></p><p><strong>13.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*un5TLV0RaEk1_0vR4ecrzg.png" /></figure><p><strong>14. Defer printed in reverse order in the below images. Analyze and answer</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qTOmPmomFpvWAGomFQrcBg.png" /><figcaption>Fig: 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2ggeZraGrzZQVx6-0ynSQ.png" /><figcaption>Fig: 2</figcaption></figure><p>Ans:</p><ol><li>defer statements will be printed before functions scope ends.</li><li>They will be printed in LIFO order that is Last In First Out order.</li><li>In the fig2 last defer is print(“3”) statement, so as this is the last defer this will be printed first and print(“2”) second and the order follows.</li></ol><p><strong>15. Difference between Encapsulation and abstraction in ios</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*uzQJIVBv0DCgLshzQRpKhg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77e116ad506" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create iOS App Programmatically without a Storyboard]]></title>
            <link>https://medium.com/@maadhavmohan/create-ios-app-programmatically-without-a-storyboard-26070816feac?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/26070816feac</guid>
            <category><![CDATA[programmatic-approach-ios]]></category>
            <category><![CDATA[app-delegate]]></category>
            <category><![CDATA[ios-app-programmatically]]></category>
            <category><![CDATA[scene-delegate]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Thu, 20 Oct 2022 17:54:19 GMT</pubDate>
            <atom:updated>2022-10-20T17:54:19.350Z</atom:updated>
            <content:encoded><![CDATA[<p>Link for the source:</p><p><a href="https://jayeshkawli.ghost.io/ios-creating-programmatic-layout-without-using-storyboard/">Creating a programmatic iOS layout without using storyboard</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26070816feac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[App States in iOS]]></title>
            <link>https://medium.com/@maadhavmohan/app-states-in-ios-8b8a781dda2e?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b8a781dda2e</guid>
            <category><![CDATA[ios-app-state]]></category>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Thu, 20 Oct 2022 08:32:23 GMT</pubDate>
            <atom:updated>2022-11-20T18:31:54.894Z</atom:updated>
            <content:encoded><![CDATA[<p>There are main five states of an iOS app:</p><ol><li>Not Running/ Unattached</li><li>Foreground Inactive/ ResignActive</li><li>Foreground Active</li><li>Background</li><li>Suspended</li></ol><p>In order to understand the app’s states flow well, we must follow the flow shown using the arrow mark in the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*7EnxoZlWKkzeR2P2FT9NPg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/0*QUJFwemHz5vvfal6.png" /><figcaption>Image from Apple Documentation.</figcaption></figure><p><strong>Not Running/ Unattached:</strong></p><ol><li>This will be the app&#39;s state when an app is not yet being tapped.</li><li>And this is the first state of the app.</li></ol><p>Possibilities that an app coming to this state are as follows:</p><ol><li>When the App is in idle state or App’s state before user tapping on its icon.</li><li>Background &gt; Not Running.</li><li>Suspended &gt; Not Running(When background or suspended app is being terminated)</li></ol><p><strong>Foreground Inactive/ ResignActive:</strong></p><ol><li>This is the second state of the app.</li><li>When user taps on an app, the app will launch and come to Foreground inactive state.</li></ol><p>Possibilities that an app coming to this state are as follows:</p><ol><li>Not Running &gt; Foreground Inactive.</li><li>Foreground Active &gt; Foreground Inactive(Due to temporary interruptions).</li><li>Background &gt; Foreground Inactive</li><li>Suspended &gt; Background &gt; Foreground Inactive</li><li>Suspended &gt; Foreground InActive(Referring to Apple Documentation Image)</li></ol><blockquote>Note: App will go to the Foreground Inactive state when some temporary interruptions happen while using the app. For example, phone call coming or we dragging notification bar down or some messages coming and displaying by totally hiding the app which we were using that time.</blockquote><p><strong>Foreground Active:</strong></p><ol><li>This is the third state of an app.</li><li>After user tapping an app, app will launch and come to foreground inactive state but it would not be in an active state.</li><li>The app will come to active state in the foreground , the moment user interacts with that page like scrolling the page or tapping any button or tapping any other UI element or messages coming after opening the app.</li></ol><p>Possibilities that an app coming to this state are as follows:</p><ol><li>Not Running &gt; Foreground Inactive &gt; Foreground Active.</li><li>Foreground Inactive &gt; Foreground Active.</li><li>Background &gt; Foreground Inactive &gt; Foreground Active.</li><li>Suspended &gt; Background &gt; Foreground Inactive &gt; Foreground Active.</li></ol><p><strong>Background:</strong></p><ol><li>This is the 4th state of the app and app will be in this state when user taps home button, or moves to another app by tapping notifications in the notications bar.</li><li>An app never comes directly to the background state when it is in Foreground Active State. Because, it first has to go to foreground inactive state and then only it move to background state.</li></ol><p>Possibilities that an app coming to Background state are as follows:</p><ol><li>Foreground Active &gt; Foreground Inactive &gt; Background.</li><li>Foreground Inactive &gt; Background.</li><li>Suspended &gt; Background.</li><li>Not Running &gt; Background.</li></ol><p><strong>Suspended:</strong></p><ol><li>This is the 5th state of an app and iOS will itself move the background state app to this state (It will move the app from background to suspended).</li></ol><p>Scenarios When iOS moves app from background to this state are:</p><ol><li>Let’s say I have 5 apps in the background state. Out of which only one app is doing some background activities. But remaining four just occupied the memory and doing nothing for quite period of time. Then iOS will look at which apps in the background are not doing any background tasks and will move them into Suspended state based on the order in which apps were pushed to background state. If app A pushed firstly to the background then it will be moved to the suspended state by iOS if does nothing in that state.</li><li>iOS removes apps from memory that were running before in the background state.</li></ol><p>Possibilities that an app coming to this state are as follows:</p><ol><li>Background &gt; Suspended</li></ol><p>App States/LifeCycle Shown in Xcode’s AppDelegate:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NdHufAe3wh2rd2knfVUcvA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b8a781dda2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apple Developer Documentation]]></title>
            <link>https://medium.com/@maadhavmohan/apple-developer-documentation-dd58625ed362?source=rss-15c371b11d0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd58625ed362</guid>
            <dc:creator><![CDATA[Maadhav Mohan]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 05:42:40 GMT</pubDate>
            <atom:updated>2022-11-20T18:41:57.117Z</atom:updated>
            <content:encoded><![CDATA[<h3>Apple Developer Documentation All Links</h3><p><strong>UIKit Framework:</strong></p><p>This link contains all the information about all the user interface views, animations , tableview and its delegates and others.</p><p><a href="https://developer.apple.com/documentation/uikit">UIKit | Apple Developer Documentation</a></p><p><strong>Link of the apple frameworks :</strong></p><p><a href="https://developer.apple.com/documentation/technologies">Technologies | Apple Developer Documentation</a></p><p><strong>Link for all the WWDC Videos</strong></p><p><a href="https://developer.apple.com/videos/all-videos/">All Videos</a></p><blockquote>Note : These videos are very very important When we start working on new Frameworks like MusicKit, Core Data, AVFoundation and many more.</blockquote><p><strong>Auto Layout Guide:</strong></p><p><a href="https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithConstraintsinInterfaceBuidler.html#//apple_ref/doc/uid/TP40010853-CH10-SW1">Working with Constraints in Interface Builder</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd58625ed362" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>