<?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 Sunee Ragu on Medium]]></title>
        <description><![CDATA[Stories by Sunee Ragu on Medium]]></description>
        <link>https://medium.com/@sunee.ragu?source=rss-2ffb6e233cac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fryNHYJM3PWevHvn</url>
            <title>Stories by Sunee Ragu on Medium</title>
            <link>https://medium.com/@sunee.ragu?source=rss-2ffb6e233cac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:35:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sunee.ragu/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[Exploring the Latest iOS App Development Trends of 2025]]></title>
            <link>https://medium.com/@sunee.ragu/exploring-the-latest-ios-app-development-trends-of-2025-750e225cc296?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/750e225cc296</guid>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 17:47:04 GMT</pubDate>
            <atom:updated>2025-09-11T17:47:04.079Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>As we journey deeper into 2025, iOS app development continues to evolve rapidly, bringing fresh opportunities and challenges for developers and users alike. From sweeping OS updates to smarter AI built right into our apps, here’s an easy-to-understand update on the latest iOS changes and what they mean for you as a developer or user.</blockquote><p><strong>1. Major OS &amp; UI Changes: From iOS 18 to iOS 26</strong></p><blockquote>Apple has doubled down on customization with iOS 18, making the Home Screen and Control Center feel truly yours. You can now place widgets and apps anywhere even above the dock! Imagine having your calendar or weather widget right at your thumb’s reach.</blockquote><blockquote><strong>Icons and widgets</strong> can adapt their colors and tints dynamically to match your wallpaper or time of day, giving your phone a subtle, elegant flair. Control Center is more flexible, letting you group controls and add shortcuts from third-party apps.</blockquote><blockquote><strong>Lock Screen buttons </strong>like flashlight and camera are now replaceable, so you can swap them out for what you use most, like quick notes or music controls.</blockquote><blockquote>iOS 26 introduces “<strong>Liquid Glass</strong>” a gorgeous new design language with glossy, translucent UI elements. It’s like your interface has a soft, glassy sheen that responds to light and motion.</blockquote><p><strong>2. SwiftUI &amp; SwiftData Maturation</strong></p><blockquote>SwiftUI has grown from a cool idea into a rock-solid framework. Animations and gestures feel buttery smooth and styling options have expanded with new materials and corner shapes.</blockquote><blockquote>For example, here’s a simple SwiftUI snippet creating a rounded, blurred button with a glossy effect that fits perfectly with the Liquid Glass style:</blockquote><pre>Button(action: {<br>    print(&quot;Button Pressed!&quot;)<br>}) {<br>    Text(&quot;Tap Here&quot;)<br>        .padding()<br>        .background(.ultraThinMaterial)<br>        .cornerRadius(12)<br>        .shadow(radius: 5)<br>}</pre><blockquote>State management has become more intuitive thanks to improved <strong>@Observable</strong> and async/await support, helping you write cleaner, more maintainable code.</blockquote><blockquote><strong>SwiftData</strong> is also emerging as a modern, simpler alternative to Core Data. Instead of wrestling with boilerplate code, you can focus on building your app’s features. Think of it as Core Data’s younger, smarter sibling.</blockquote><p><strong>3. AI and Machine Learning Are Everywhere</strong></p><blockquote><strong>AI</strong> is now a staple in app development not just a flashy feature, it’s a core part of modern app development. Core ML lets you run intelligent models right on the device, preserving privacy and speeding up responses.</blockquote><blockquote>Imagine a fitness app that learns your workout habits and suggests personalized routines or a messaging app that predicts your replies based on your style all without sending your private data to the cloud.</blockquote><p><strong>4. Privacy, Security, and Growing Regulations</strong></p><blockquote>Apple is raising the bar on privacy, requiring apps to request very specific permissions. Want to share a contact? You might only be able to share one or two instead of your whole list.</blockquote><blockquote>You can now hide or lock apps, so they don’t clutter your search or send notifications, perfect for sensitive apps like finance or health trackers.</blockquote><blockquote>App Store policies require transparency, meaning your users will know exactly how their data is used.</blockquote><p><strong>5. AR, VR and Cross-Device Experiences</strong></p><blockquote>Apple’s Vision Pro and visionOS are pushing app experiences beyond phones and tablets. Your app could live across devices like your phone, glasses and even future hardware.</blockquote><blockquote>ARKit improvements mean apps can create more realistic, interactive AR worlds. Picture an interior design app that lets you virtually walk through your redecorated living room, with real-time lighting and shadows thanks to LiDAR.</blockquote><p><strong>6. Performance, 5G and Edge Computing</strong></p><blockquote>With better 5G coverage, apps can stream high-quality content and offer real-time features with minimal delay. Edge computing lets apps process data locally, improving speed and privacy.</blockquote><blockquote>For example, a video chat app might use on-device AI to improve your background blur without sending your video feed to servers.</blockquote><p><strong>7. Design Trends: UI, UX and Visuals</strong></p><blockquote>The new “Liquid Glass” design trend means translucent, glossy UI elements that feel modern and tactile. Users can customize themes, dark modes and tints to their liking.</blockquote><blockquote>Developers can use new SwiftUI materials to easily create this look, like <strong>.ultraThinMaterial</strong> or <strong>.thickMaterial</strong>, which adjust automatically to the background and lighting.</blockquote><p>⚠<strong> What to Watch Out For</strong></p><blockquote><strong>Backward compatibility</strong> is trickier as iOS gets more advanced.</blockquote><blockquote><strong>Testing</strong> grows complex with multiple devices and UI states.</blockquote><blockquote><strong>On-device ML/AR</strong> uses more resources, so performance tuning is essential.</blockquote><blockquote><strong>Privacy</strong> demands more transparency and careful handling of AI features.</blockquote><p><em>iOS development in 2025 is a balancing act between cutting-edge tech and practical user needs. With SwiftUI’s maturity, smarter AI and bold new design, the future is bright but challenges remain.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=750e225cc296" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I’d Answer 2025 iOS Interview Questions-Junior vs Senior Perspective (Part 2)]]></title>
            <link>https://medium.com/@sunee.ragu/how-id-answer-2025-ios-interview-questions-junior-vs-senior-perspective-part-2-62255b9d20d3?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/62255b9d20d3</guid>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 19:21:21 GMT</pubDate>
            <atom:updated>2025-08-25T19:21:21.784Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 2: Top iOS Interview Questions (6–10)</em></p><h4>6. What are weak and unowned references? When do you use each?</h4><blockquote><strong>Junior to Mid-Level Answer: </strong>In Swift, both weak and unowned are used to prevent <strong>retain cycles</strong>, which can cause memory leaks. weak is an optional reference. It automatically becomes nil when the object it points to is deallocated. I usually use weak for delegates or in closures inside view controllers to avoid strong reference cycles.</blockquote><pre>weak var delegate: SomeDelegate?</pre><blockquote>This helps make sure the view controller doesn’t keep the delegate alive if it’s supposed to go away.unowned is non-optional. It assumes the object will always be there when accessed. It doesn&#39;t get set to nil, so if the object is gone and I try to access it, the app will crash. So I use weak when the object can go away, and unowned only when I’m sure it won’t.</blockquote><blockquote><strong>Senior-Level Answer: </strong>weak and unowned are tools to break strong reference cycles, but I choose between them based on <strong>object ownership semantics and lifecycle guarantees</strong>.</blockquote><blockquote>I use weak when the reference should not keep the object alive, and where it’s okay for that object to become nil—typically in <strong>delegate patterns</strong>, <strong>child-to-parent relationships</strong> or <strong>UI closures</strong>. It adds safety and avoids crashes by allowing the reference to be nil.</blockquote><blockquote>I use unowned when I’m confident the referenced object <strong>will outlive</strong> the reference. This is useful in <strong>closures owned by long-lived objects</strong>, like services or coordinators, where the captured object (like a view model) is guaranteed to stay alive as long as the closure exists.</blockquote><blockquote>Example: In a Coordinator pattern, I might store child view controllers as weak to avoid retain cycles. But in a networking service that holds a closure referencing a view model, I may use unowned if that view model clearly owns the service and outlives it.</blockquote><blockquote>I’m cautious with unowned in contexts where deallocation timing is uncertain—especially with UI elements or async operations because a crash risk often outweighs the benefit of avoiding an optional.</blockquote><h4>7. What’s the difference between <em>@StateObject</em>, <em>@ObservedObject</em>, and <em>@EnvironmentObject</em> in SwiftUI?</h4><blockquote><strong>Junior to Mid-Level Answer: </strong>In SwiftUI, these three property wrappers help manage how data is shared and updated across views.</blockquote><blockquote>@StateObject is used when the <strong>view creates and owns</strong> the observable object. I use it in the parent or root view where the object is first initialized. @ObservedObject is used when a <strong>child view gets an object passed in</strong> and just needs to observe changes. @EnvironmentObject is used for <strong>shared/global data</strong>, injected from a higher level like the root view, and accessible across many views without explicitly passing it down.</blockquote><blockquote><strong>Example: </strong>I had a UserSession class to track login state. I initialized it with @StateObject in the root view and then used @EnvironmentObject in child views like ProfileView or SettingsView to access the session data.</blockquote><blockquote><strong>Senior-Level Answer: </strong>In SwiftUI, understanding how data flows through views is critical, especially with observable objects.@StateObject is for creating and <strong>owning</strong> the lifecycle of an observable object. It&#39;s essential to use this when the view should <strong>initialize the object once</strong> and maintain it across view reloads. @ObservedObject is for <strong>non-owning views</strong> that simply observe an object passed to them—commonly used in <strong>child views</strong>.@EnvironmentObject is for <strong>shared dependencies</strong> injected into the environment. It’s clean and scalable when multiple views need access to the same data without tight coupling.</blockquote><blockquote><strong>Example: </strong>In one project, UserSession managed authentication state. I initialized it as a @StateObject inside AppView and injected it into the environment. Then across the app, in views like LoginView, ProfileView, and even modals, I used @EnvironmentObject to access the session.</blockquote><blockquote>As a senior dev, I also make sure to <strong>document ownership clearly</strong> in code comments or protocols. This avoids bugs from accidentally re-creating objects or losing state when views refresh.</blockquote><h3>8. How do you manage dependencies in iOS projects?</h3><blockquote><strong>Junior to Mid-Level Answer: </strong>I’ve worked with <strong>CocoaPods</strong>, <strong>Carthage</strong> and <strong>Swift Package Manager</strong>. These days, I prefer <strong>Swift Package Manager (SPM)</strong> because it’s built into Xcode, easy to use and works well for most popular libraries. For example, when I need to add libraries like <strong>Alamofire</strong> or <strong>SDWebImage</strong>, I use <strong>Swift Package Manager</strong> if the project is using it. If the codebase is already using CocoaPods, I’ll stick with that to keep things consistent. I also try to keep dependency versions pinned to avoid surprises during updates.</blockquote><blockquote><strong>Senior-Level Answer:</strong> I typically prefer Swift Package Manager (SPM) for modern iOS codebases. It integrates directly with Xcode, avoids the overhead of managing workspaces, and works especially well in modular architectures. For example, in a <strong>financial app</strong> where we managed user accounts and transactions, we <strong>organized the codebase into private Swift packages</strong> — like CoreUI, Networking, and AuthFeature.</blockquote><blockquote><strong>This approach gave us:</strong> Clean separation of concerns, Faster CI builds, Easier testing and version control.</blockquote><blockquote>To manage <strong>runtime dependencies</strong>, I used a <strong>dependency injection container</strong> like <strong>Resolver</strong> or <strong>Factory</strong>. To manage runtime dependencies, I used a dependency injection container like Resolver or Factory. This allowed us to inject services such as API clients and authentication managers without creating tight coupling between modules, making the app more testable and scalable as the project grew.</blockquote><h3>9. How do you test your iOS apps?</h3><blockquote><strong>Junior to Mid-Level Answer: </strong>I mainly use XCTest for writing unit tests and when possible, I add UI tests as well. For example, in a login screen, I write unit tests to check if the <strong>login button gets enabled or disabled</strong> based on the form input. I also <strong>mock network services</strong> to test how the app handles different API responses without hitting the real backend. When testing asynchronous functions, like API calls or timers, I use **XCTestExpectation** to wait for the result and make sure the logic completes correctly.</blockquote><blockquote><strong>Senior-Level Answer: </strong>I write <strong>unit</strong>, <strong>integration</strong>, and <strong>UI tests</strong>, depending on the scope and risk. I focus heavily on <strong>ViewModels and business logic</strong> where the critical behavior lives.</blockquote><blockquote><strong>Example: </strong>In an onboarding flow, I wrote unit tests to:</blockquote><blockquote>Validate form logic.</blockquote><blockquote>Mock API responses for different success/failure states.</blockquote><blockquote>Use XCTestExpectation to handle async operations.</blockquote><blockquote>For UI testing, I added <strong>screenshot tests</strong> to detect layout regressions across different screen sizes.</blockquote><blockquote>All tests were automated through a <strong>CI pipeline using Fastlane</strong>, so every pull request ran a full test suite before merging.</blockquote><h3>10. Tell me about a challenging bug you fixed.</h3><blockquote><strong>Junior to Mid-Level Answer: </strong>Sure! I once ran into an issue where a <strong>view controller wasn’t being deallocated after dismissal</strong>. I debugged it and realized the problem was a <strong>retain cycle,</strong> a closure inside the view model was capturing self strongly and the view controller was holding onto the view model. I fixed it by using [weak self] in the closure and added a deinit print statement to confirm the view controller was being released. It was a great lesson in <strong>memory management</strong> and how closures can easily introduce leaks.</blockquote><blockquote><strong>Senior-Level Answer: </strong>Definitely. I had a tricky case in <strong>SwiftUI</strong> where a view was <strong>redrawing far too often</strong>, causing performance issues during animations. After digging in, I found that the issue came from using @ObservedObject on a view that only needed a small piece of state. A <strong>deeply nested model change</strong> was triggering unnecessary re-renders.</blockquote><blockquote><strong>Fix: </strong>I refactored the view to use @Binding instead, limiting the updates to only the state it actually needed. That reduced redraws and made the animation much smoother. That experience reinforced the importance of understanding <strong>SwiftUI’s property wrappers</strong> and how they impact rendering performance.</blockquote><p>These answers are based on my perspective and experience but the real value comes when you adapt them to <strong>your own</strong> work.</p><p>If you’re a <strong>junior developer</strong>, focus on understanding the core concepts so you can explain them clearly.<br>If you’re preparing for a <strong>senior role</strong>, back your answers with real examples that’s what shows depth and practical understanding.</p><p>Use this as a guide, but let your answers reflect <strong>your journey</strong>.</p><p><strong>All the best! 👊</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62255b9d20d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I’d Answer iOS Interview Questions in 2025 — Junior vs Senior Developer Perspective (Part 1)]]></title>
            <link>https://medium.com/@sunee.ragu/how-id-answer-ios-interview-questions-in-2025-junior-vs-senior-developer-perspective-part-1-c130941dad6a?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/c130941dad6a</guid>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 20:51:51 GMT</pubDate>
            <atom:updated>2025-07-24T17:10:35.885Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*EFcZEvdQaG9MTkFBn6z0TA.jpeg" /></figure><h3>iOS Interview Questions 2025: Junior vs Senior Takes (Part 1)</h3><blockquote>Part 1: Top iOS Interview Questions (1–5)</blockquote><h3><strong>1. What’s the difference between struct and class in Swift?</strong></h3><blockquote>J<strong>unior to mid-level Answer: </strong>In Swift, struct is a <strong>value type</strong> and class is a <strong>reference type</strong>. This means when I assign a struct to another variable or pass it to a function, it gets <strong>copied</strong> — each instance is independent. But with classes, both variables <strong>point to the same instance</strong> in memory. <br><strong>Example</strong>: If I have a User struct and assign it to another variable, changing the name in one won’t affect the other. But if it were a class, both would reflect the change. I typically use struct for simple data models like User or Post, because they’re lightweight and help avoid unexpected side effects.</blockquote><blockquote><strong>Senior Level Answer: </strong>While struct and class differ primarily as value vs reference types, at a senior level, the decision involves <strong>architecture and intent</strong>. I default to using struct for most model types — they offer <strong>immutability</strong>, <strong>predictability</strong>, and <strong>performance </strong>benefits. Value types reduce bugs by avoiding unintended sharing of state, and they’re often stack-allocated, which is efficient. I use class when I need <strong>shared mutable state</strong>, <strong>identity</strong>, or <strong>inheritance</strong>. This is common in services, UI components, or long-lived objects.<br><strong>Example</strong>: In a social feed app, Post was a struct so changes wouldn’t unintentionally affect other views. But PostServicewas a class, since it managed live data and was shared across multiple views using Combine.</blockquote><h3><strong>2. What is ARC in Swift and how do you manage memory?</strong></h3><blockquote>J<strong>unior to mid-level Answer: </strong>ARC stands for <strong>Automatic Reference Counting</strong> — it’s how Swift manages memory under the hood. ARC automatically frees up memory when an object is no longer being used (i.e., when its reference count drops to zero). However, if two objects <strong>strongly reference each other</strong>, they create a <strong>retain cycle</strong>, and ARC can’t release them. That’s where weak or unowned references come in — they break the cycle.</blockquote><blockquote><strong>Example</strong>: When I use closures in a view controller, I often write:</blockquote><pre>[weak self] in</pre><blockquote>This prevents the closure from strongly capturing self and causing a memory leak. I’ve seen bugs or even crashes when this wasn’t handled properly, especially with async API calls or view models holding onto view controllers.</blockquote><blockquote><strong>Senior-Level Answer: </strong>ARC (Automatic Reference Counting) tracks how many <strong>strong references</strong> an object has. When the count hits <strong>zero</strong>, the object is deallocated. In more complex architectures, ARC issues often show up in: <strong>Closures, Delegate relationships, Combine or async pipelines</strong></blockquote><blockquote>To manage memory safely, I consistently: Use <strong>[weak self]</strong> or <strong>[unowned self]</strong> in closures. Mark delegate properties as weak (especially in UIKit or custom delegation). Manage Combine pipelines using <strong>AnyCancellable</strong> and <strong>.store(in:). </strong>Avoid strong captures in tasks, async operations, and reactive chains</blockquote><blockquote><strong>Example</strong>: In a media-heavy app, a ViewModel captured its ViewController strongly in a Combine sink, causing a retain cycle. We fixed it using [weak self] in the closure and storing cancellables in a deinit-safe pool.</blockquote><blockquote>I also use tools like <strong>Memory Graph Debugger, Instruments — Leaks and Allocations. </strong>Occasionally run <strong>leak detection in CI pipelines</strong> to catch issues before they hit production.</blockquote><blockquote><strong>Note:</strong> If any tools above are new to you, it’s a great opportunity to explore them — they’re essential in any iOS developer’s toolkit.</blockquote><h3><strong>3. Explain MVC and why we often move to MVVM or VIPER.</strong></h3><blockquote>J<strong>unior to mid-level Answer:</strong><br> MVC stands for <strong>Model-View-Controller</strong>: <strong>Model</strong> holds the data, <strong>View</strong> handles the UI, <strong>Controller</strong> connects them and manages interactions. In iOS, though, the Controller often takes on too much — networking, UI updates, logic — which is why it’s jokingly called <strong>“Massive View Controller.” </strong>That’s where <strong>MVVM (Model-View-ViewModel)</strong> comes in. I’ve used MVVM to move business logic into the ViewModel. This makes the view controller lighter and easier to test.<br> For example, in a login screen, the ViewModel handles validation and login state, and the view controller simply observes changes and updates the UI.</blockquote><blockquote><strong>Senior-Level Answer:</strong><br> I choose architecture based on project size, team structure, and testing needs. For <strong>small to mid-sized apps</strong>, I often use <strong>MVVM</strong> with <strong>Combine</strong> or <strong>SwiftUI</strong> for reactive state handling. For <strong>large or enterprise apps</strong>, I prefer <strong>VIPER</strong> or <strong>Clean Architecture</strong> to clearly separate responsibilities — especially when features are developed by multiple teams. I also use the <strong>Coordinator pattern</strong> in UIKit apps to decouple navigation logic from view controllers. In one of the enterprise projects, we migrated from MVC to MVVM. This not only improved testability and scalability but also made onboarding easier and code ownership more manageable.</blockquote><blockquote>💡 <em>Tip: If you’re curious about scaling architectures like Clean Swift or Coordinators add them to your reading list.</em></blockquote><h3><strong>4. How do you handle concurrency in Swift?</strong></h3><blockquote>J<strong>unior to mid-level Answer:</strong><br> Swift now supports <strong>async/await</strong>, which makes handling concurrency much simpler than older approaches like completion handlers or DispatchQueue.</blockquote><blockquote>For example:</blockquote><pre>let data = try await fetchUserData()</pre><blockquote>I often use this for API calls, like loading a feed or user profile. It keeps the code clean and easier to follow. When updating the UI after async operations, I make sure those updates happen on the <strong>main thread</strong>, either explicitly or by using <strong>@MainActor</strong>. I also use Task { } to start async operations and apply @MainActor in ViewModels to keep UI updates thread-safe.</blockquote><blockquote><strong>Senior-Level Answer: </strong>Since <strong>Swift 5.5</strong>, I’ve leaned heavily into <strong>structured concurrency</strong> with async/await, Task and <strong>actors</strong> for safer, more predictable concurrency.</blockquote><blockquote>Best practices I follow is to use <strong>actors</strong> to protect shared mutable state without locks, use <strong>@MainActor</strong> for UI updates to guarantee main-thread execution. Avoid capturing strong references inside Task closures — especially view controllers. Handle cancellation explicitly with Task.checkCancellation() in long-running operations. In one performance-sensitive sync engine, I used a dedicated <strong>actor</strong> to batch and serialize Core Data writes. This ensured thread safety without blocking the main thread or introducing race conditions.</blockquote><h3>5. What is a memory leak? How do you debug it?</h3><blockquote><strong>Junior to Mid-Level Answer:</strong><br> A memory leak happens when objects stay in memory longer than they should — <strong>even when they’re no longer reachable or used</strong> — usually because of retain cycles. That’s when two or more objects hold strong references to each other, so ARC can’t free them. <strong>For example:</strong> If a view controller has a closure that captures self strongly, it won’t get deallocated.</blockquote><pre>someAsyncCall { [weak self] in<br>self?.updateUI()<br>}</pre><blockquote>I use <strong>Xcode’s Memory Graph Debugger</strong> to detect leaks. It visually shows which objects are still in memory. I also use <strong>Instruments &gt; Leaks</strong> to track live allocations. A common issue I faced: forgetting to invalidate a Timer, which kept the view controller alive. Setting the timer to nil and breaking the cycle fixed it.</blockquote><blockquote><strong>Senior-Level Answer:</strong><br> Memory leaks stem from <strong>unreleased references</strong>, typically due to retain cycles in closures, delegates, Combine pipelines or lingering timers.</blockquote><blockquote>My leak-debugging approach includes: Using <strong>Xcode’s Memory Graph Debugger</strong> after deallocations should’ve occurred, Running <strong>Instruments — Allocations &amp; Leaks</strong> in CI or manually during stress testing, Enabling runtime diagnostics like <strong>Malloc Stack Logging</strong>.</blockquote><blockquote>Common strategies I use: Use <strong>[weak self]</strong> or <strong>[unowned self] </strong>in closures, delegates as weak to prevent cycles, Manage Combine subscriptions with AnyCancellable and .store(in:) properly, Ensure async tasks or timers are invalidated and don’t retain unnecessary references.</blockquote><blockquote>In one app, a Combine pipeline retained its ViewModel, which retained the ViewController. Refactoring with [weak self] and storing subscriptions correctly fixed the leak. We also now run leak detection tools on CI before releases. I always aim to catch memory leaks early — during development, not after release.</blockquote><p><strong><em>💡 Stay tuned for Part 2 (Questions 6–10) — follow me to get notified.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c130941dad6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Swift 5.8 and SwiftUI: The Latest Updates You Should Know (2025)]]></title>
            <link>https://medium.com/@sunee.ragu/whats-new-in-swift-5-8-and-swiftui-the-latest-updates-you-should-know-2025-f78b8c9411e5?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/f78b8c9411e5</guid>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 21:01:31 GMT</pubDate>
            <atom:updated>2025-07-19T21:01:31.597Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been a while since I last posted, but I’m excited to dive back into writing about iOS development, especially with all the cool updates Swift and SwiftUI have received recently. Whether you’re a beginner or an experienced developer, these new features will help you build better apps more efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*6TRa6Ii5jS5CYatT8eOQEg.png" /><figcaption>Swift 5.8 &amp; SwiftUI: Smarter, Faster, Cleaner</figcaption></figure><h3><strong>1. Enhanced Async/Await in Swift 5.8</strong></h3><p>Swift’s concurrency model keeps getting better. The latest updates make it easier to write asynchronous code that’s clean and safe. You can now handle async tasks with even less boilerplate, improving app responsiveness.</p><pre>import Foundation<br><br>// Simulated network fetch function using async/await<br>func fetchUserData() async throws -&gt; String {<br>    try await Task.sleep(nanoseconds: 1_000_000_000) // Simulate 1 second delay<br>    return &quot;User data loaded&quot;<br>}<br><br>// Calling the async function<br>@main<br>struct MyApp {<br>    static func main() async {<br>        do {<br>            let result = try await fetchUserData()<br>            print(result)  // Output: User data loaded<br>        } catch {<br>            print(&quot;Failed to fetch user data: \(error)&quot;)<br>        }<br>    }<br>}</pre><p><em>With Swift 5.8, you can now use </em><strong><em>async</em></strong><em> directly in the </em><strong><em>main</em></strong><em> entry point, making async code easier to write and read.</em></p><h3><strong>2. New SwiftUI Views and Modifiers — .containerBackground</strong></h3><p>SwiftUI introduced the <strong>.containerBackground</strong> modifier, which lets you add beautiful, adaptive background effects to your views with minimal effort.</p><pre>import SwiftUI<br><br>struct ContentView: View {<br>    var body: some View {<br>        Text(&quot;Hello, SwiftUI!&quot;)<br>            .padding()<br>            .containerBackground(.thinMaterial) // Adds a translucent background<br>    }<br>}</pre><p><em>This modifier automatically adapts to the environment, giving your app a modern look with just one line of code.</em></p><h3><strong>3. Better UIKit Integration</strong></h3><p>SwiftUI now supports seamless integration with UIKit components, allowing you to embed UIKit view controllers easily inside SwiftUI views.</p><pre>import SwiftUI<br>import UIKit<br><br>class MyViewController: UIViewController {<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        view.backgroundColor = .systemBlue<br>    }<br>}<br><br>struct MyViewControllerWrapper: UIViewControllerRepresentable {<br>    func makeUIViewController(context: Context) -&gt; MyViewController {<br>        return MyViewController()<br>    }<br><br>    func updateUIViewController(_ uiViewController: MyViewController, context: Context) {}<br>}<br><br>struct ContentView: View {<br>    var body: some View {<br>        MyViewControllerWrapper()<br>            .edgesIgnoringSafeArea(.all)<br>    }<br>}</pre><p><em>This flexibility means you can gradually adopt SwiftUI while still using UIKit where needed.</em></p><h3><strong>4. Improved Performance and Tooling</strong></h3><p>Swift 5.8 brings compiler improvements that reduce build times and boost runtime performance. Plus, new compile-time checks help you write version-aware code:</p><pre>#if swift(&gt;=5.8)<br>print(&quot;Running Swift 5.8 or later!&quot;)<br>#else<br>print(&quot;Running an earlier Swift version.&quot;)<br>#endif</pre><p><em>Using these directives, you can ensure your codebase leverages new features when available without breaking compatibility.</em></p><p>These updates make Swift and SwiftUI more powerful and enjoyable to work with. I encourage you to try them out and see how they can simplify your app development process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f78b8c9411e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift iOS Two Sums Interview Question in Data structure and Algorithm in Swift iOS]]></title>
            <link>https://medium.com/@sunee.ragu/swift-ios-two-sums-interview-question-in-data-structure-and-algorithm-in-swift-ios-4c93accd899?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c93accd899</guid>
            <category><![CDATA[two-sum]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Tue, 20 Dec 2022 22:29:10 GMT</pubDate>
            <atom:updated>2022-12-20T22:29:10.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>Swift iOS Two Sums Interview Question in Data structure and Algorithm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*IroATAK1EauO3Lfu2TmKnw.jpeg" /></figure><p><strong>Two Sums </strong>: Given an array of integers nums and an integer target, return <em>indices of the two numbers such that they add up to </em><em>target</em>. You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> element twice. You can return the answer in any order.</p><p><strong>Example :</strong></p><p><em>Input: nums = [2,7,11,15], target = 9<br>Output: [0,1]</em></p><p><strong>Answer:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*-dkuZynQC9fR_yUEMo6JRw.png" /></figure><p><strong>Explanation:</strong></p><p>When we were analyzing the problem, we came across the following equation <strong>c = a + b, </strong>but can we write the above equation as -&gt; <strong>b = c — a </strong>It can iterate through the array only once and calculate the difference of target © and the current element (a) and find the other element (b).</p><p>The idea is as follows -&gt;Loop through the array to Check if i have encountered the current element before. If i have, i will return the index of this element and the index of the difference of the target and the current element. I will only encounter this element before only , if we have saved the difference of target and the element which when added to the current element gives the target itself.</p><p>This is confusing I know but once it clicks, it’s very obvious.</p><p>If we haven’t, then i will save the difference of the target and current element. Repeat the process.</p><p>Since I need to store our difference, I need a data structure which can store the difference and its corresponding index. We need a Map where we will store the difference as key and the corresponding index as value.</p><p><strong>Time Complexity: </strong>Since we are iterating the array only once, the time complexity would be O(n).</p><p><strong>Space Complexity: </strong>Since we need a Map of the size of the array, the space complexity would be O(n).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c93accd899" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behavioral and General Interview Questions for iOS Developer 2022]]></title>
            <link>https://medium.com/@sunee.ragu/behavioral-and-general-interview-questions-for-ios-developer-2022-fb2c6d7a9b1c?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb2c6d7a9b1c</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[latest]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[2022]]></category>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Mon, 31 Oct 2022 19:21:33 GMT</pubDate>
            <atom:updated>2022-10-31T19:21:33.543Z</atom:updated>
            <content:encoded><![CDATA[<p>Usually when interview is near we brush up our technical knowledge. Sometimes interviewers focus on behavioral questions and general questions too. I would like to share some of the questions i faced during the interview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKENxICL-41DH0iIXP8MLw.png" /></figure><h3>Key Notes</h3><ul><li><em>Interviewers ask behavioral interview questions because your response gives them a good sense of how you’ll perform if you’re hired.</em></li><li><em>The more you know about the role, industry, and company, the better you’ll be able to emphasize your most relevant qualifications and experience, so take the time to do your research.</em></li><li><em>To ace your response, come prepared with examples and stories to share.</em></li></ul><p><strong>Why should we hire you?</strong></p><blockquote><strong>Sample answer</strong>: I believe that my experience with technology, specifically in the mobile application, make me the best match for this position. I am hard working, dedicated and quick learner. S<em>o I’m confident I will be able to step into this role and begin contributing quickly.</em></blockquote><p><strong>why do you want to work for us?</strong></p><blockquote><strong>Sample answer: </strong><em>I feel that my technical skills are an excellent fit for this role. This company has a wonderful reputation as a great place to work. This firm has the reputation of being one of the leading company with a list of impressive customers as well as high customer satisfaction rates.</em></blockquote><p><strong>Where do you see yourself in 5 years?</strong></p><blockquote><strong>Sample answer: </strong>Over the next few years, I want to explore and develop skills in Mobile applications. In five years, I want to have gained experience in leading projects for major clients. I will be looking for opportunities to expand my responsibilities within this role to work towards my goal.</blockquote><p><strong>What is one time you experienced failure and how did you deal with it?</strong></p><blockquote><strong>Sample answer: </strong>Three people were responsible for submitting one assignment, but only two were available, didn’t communicate with my coworkers about their availability. We worked as a team and established a solution, and submitted separate parts instead. We were not able to meet deadline. The important thing I learned from this incident was always to make sure everyone on the team knows their responsibilities upfront to avoid confusion later on.</blockquote><p><strong>Tell me about a time you had a disagreement with a team member?</strong></p><blockquote><strong>Sample answer: </strong>Difficult work situations can sometimes require complex solutions, but I believe in approaching these problems from mutual respect and understanding. I would try not to take it too personally while still firm about the best course of action. The ability to disagree without being disagreeable is vital for any organization that wants to stay productive. Add</blockquote><p><strong>Describe one instance where you had to overcome a problem, how did you overcome it?</strong></p><blockquote>Explain a problem relate to your project and how you solved the problem.</blockquote><p><strong>What was a project that you were most proud of? Describe an interesting project you are working on?</strong></p><blockquote>Prepare in advance. This is a common interview question, so it’s ideal to prepare an answer ahead of time. …</blockquote><blockquote>Use the STAR interview technique. …</blockquote><blockquote>Be specific and concise. …</blockquote><blockquote>Include measurable outcomes. …</blockquote><blockquote>Explain your role. …</blockquote><blockquote>Stay positive.</blockquote><p><strong>Describe your most difficult challenge and how you approached it?</strong></p><blockquote>Consider previous challenges you’ve faced. …</blockquote><blockquote>Tailor your answer to the job description. …</blockquote><blockquote>Be specific about why they were challenges. …</blockquote><blockquote>Be honest. …</blockquote><blockquote>Make sure your answers present you in a positive light. …</blockquote><blockquote>Use nonprofessional examples if necessary.</blockquote><p><strong>What are some good coding practices?</strong></p><blockquote><strong>Code indentation: </strong>Proper indentation is the most important thing you can do to ensure that your code is readable and easy to understand.</blockquote><blockquote><strong>Meaningful naming: </strong>Code variable names and function names should be intuitive. Ideally, we should be able to guess what a function does based on the function’s name.</blockquote><blockquote><strong>Comments that add context: </strong>Even if other best practices are accounted for, source code can’t always be self-explanatory. When code can’t explain itself, comments should step in.</blockquote><blockquote><strong>Don’t repeat yourself: Don’t repeat yourself t</strong>o reduce code duplication. The idea here is that if you have code that’s doing the same thing twice, it should be made into a function. <strong>By abstracting code into functions, you can reuse that code and make development more efficient</strong>.</blockquote><blockquote><strong>Low coupling and high cohesion : </strong>Low coupling and high cohesion are different yet complementary principles. Low coupling encourages separation between unrelated parts of a codebase, while high cohesion encourages integration between related parts of a codebase.</blockquote><blockquote><strong>Consider your context: </strong>Coding guidelines vary across different contexts. Depending on your programming language, company, or industry, there may be different coding guidelines for naming conventions, coding style, indentation, and file structures. Be mindful of your project’s individual needs and honor those coding standards when you can.</blockquote><p><strong>What is a good example of working in a team?</strong></p><blockquote>Listening: An example of successful teamwork is <strong>effective active listening skills</strong>. Maintaining eye contact when others are talking, having open and friendly body language, and responding appropriately to the questions and comments of others establishes a professional work environment and shows good teamwork.</blockquote><h3><strong>Conclusion:</strong></h3><p><strong><em>Learn as much as you can about the company and the role. </em></strong><em>The more you know about the job and the company, the easier it will be to respond to interview questions.</em></p><p><em>Take the time to research the company prior to your interview, and review the job posting, so you’re as familiar as possible with the role.</em></p><p><em>Learn how to use the STAR(Situation, Task, Action, Result) technique to give well thought out and complete answers.</em></p><p><em>“All the best”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb2c6d7a9b1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top iOS interview questions and answers]]></title>
            <link>https://medium.com/@sunee.ragu/top-ios-interview-questions-and-answers-7cd84e1793ea?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cd84e1793ea</guid>
            <category><![CDATA[latest]]></category>
            <category><![CDATA[frequently-asked-queries]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-interview-question]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 22:03:03 GMT</pubDate>
            <atom:updated>2022-10-10T17:38:50.948Z</atom:updated>
            <content:encoded><![CDATA[<h3>Top iOS interview questions and answers 2022</h3><h3><strong>What is Unit Testing in iOS? What are the benefits ?</strong></h3><p>A unit test case is a function that validates the piece of code in both successful &amp; failed scenarios. To check functions and API’s we write the test cases, no need to run all the project we can run particular function. Include unit test-related to check-function-api’s. Include UiTest-related to storyboard, XCTest Framework. Handles test driven development. Some of the test cases to validate the functionality are <strong>XCTAssertNil, XCTAssertNotNil, XCTAssertEqual, XCTAssertTrue, XCTAssertFail</strong></p><p><strong>Benefits of Unit Testing:</strong></p><p><strong>Improve Code Quality: </strong>By adding test cases in the application, allows to know the code bugs, object allocation-deallocation, crashes, success &amp; failure which makes the application robust with minimum bugs.</p><p><strong>Identify Bugs Easily:</strong> When we cover the code in the unit test cases with all possible end user scenarios, the bugs can be easily identified during the time of development before it goes to quality assurance.</p><p><strong>Avoid App Crash:</strong> As engineers check all the null values &amp; object allocation-deallocation, the application crashes can be easily avoided.</p><p><strong>Reduce Bug Fix Cost:</strong> Unit test case application with minimum bugs reduces the QA cycles which in turn reduces the testing costs.</p><p><strong>Handle Corner Cases:</strong> Occurring outside the normal operating cases, these corner cases though less can be covered in unit testing.</p><p><strong>Cover Different User Scenarios:</strong> It covers possible use case scenarios for the same piece of code.</p><p><strong>What is UITesting in iOS?</strong></p><p><strong>UITesting</strong>: Apple provides us with a native framework called XCTest for UI testing.</p><p>UI testing allows to automate the procedure, every time when you update the code, Xcode will automatically test whether the app works correctly without doing manually.</p><p>The implementation of UI tests is based on three major classes:</p><p><strong>XCUIElement, XCUIApplication, XCUIElementQuery</strong></p><p><strong>XCUIElement</strong> is the base class that is a UI element in an application that provides with functionality for gestural interactions on iOS and mouse and keyboard interactions on macOS. The common methods are tap(), click(), and various methods related to swipe gestures. To determine if a particular element exists within the app’s current UI hierarchy, use the exists instance property.</p><p><strong>XCUIApplication</strong> is a subclass of XCUIElement that helps to launch, monitor, and terminate the app in a UI test.</p><p>You can create an instance in your test class and then call launch() on it in the setUpWithError() method.</p><p><strong>XCUIElementQuery</strong> class is responsible for finding elements in the view using different types of queries. The query should return a unique UI element.</p><p><strong>What is GraphQL in Swift iOS?</strong></p><p>GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. It provides an approach to developing web APIs, and has been compared and contrasted with REST and other web service architectures. It allows clients to define the structure of the data required, and the same structure of the data is returned from the server, <strong>therefore preventing excessively large amounts of data from being returned</strong>, but this has implications for how effective web caching of query results can be. The flexibility and richness of the query language also adds complexity that may not be worthwhile for simple APIs. It consists of a type system, query language and execution semantics, static validation, and type introspection.</p><p><strong>Name the 5 Control Transfer Statements and Describe How to Use them?</strong></p><p>Change the order in which code is executed by transferring control from one piece of code to another.</p><p>There are five control transfer statements.</p><p><strong>Break</strong>-Ends execution of an entire control flow immediately. Can use break inside a switch or loop, When we want to terminate the execution of the statement earlier.</p><p><strong>Continue</strong>- Tells the loop to stop what it is doing and start again at the beginning of the next iteration through the loop</p><p><strong>Fallthrough</strong>- Last line of the case transfer manually to next case</p><p><strong>Throw</strong>- is used to stop current execution of function or methods and throw error message based on requirement.</p><p><strong>Return</strong>- Used in functions or methods to return the value based on requirement.</p><p><strong>What is the difference between Let and Var in swift?</strong></p><p>In swift language, we can declare a constant and variable using Let and Var keyword.</p><p><strong>Let: </strong>Let keyword is immutable, it is used to declare a constant variable, and the constant variable cannot be changed once they are initialized.</p><p><strong>For Example:</strong> let myAge = 25</p><p>We cannot change the value of age, you can declare the constant value of it only once using the let keyword.</p><p><strong>Var: </strong>Var keyword is mutable, and is used to declare a variant variable. These variant variables can change the run time.</p><p><strong>For Example:</strong></p><p>var myName = “Dell”</p><p>we can change the value of name = “Apple”.</p><p><strong>What is a delegate in swift?</strong></p><p>Delegate is a design pattern, which is used to pass the data or communication between structs or classes. Delegate allows sending a message from one object to another object when a specific event happens and is used for handling table view and collection view events. Delegates have one to one relationship and one to one communication.</p><p><strong>What is Singleton?</strong></p><p>Singleton is a design pattern. A singleton is a class that has only one instance. It can be accessed globally, that is anywhere in application code. It is a shared instance of a class. Classes like Notification Center, User defaults, File Manager have shared or default properties that are Singleton.</p><p>In swift only classes can be singleton not structure. Structures are value types and copies are created every time when you pass a value to a function or a type.</p><p><strong>What is MVVM?</strong></p><p>MVVM is a design pattern, Model View ViewModel. In MVVM, view and controller are treated as one component. In MVC, the ViewController was overloaded with activities like networking, handling of signals from UI, collecting back the response. ViewModel, divide and delegate the responsibility of the ViewController.</p><p><strong>Components:</strong> <strong>Model</strong> is used by ViewModel and updates whenever ViewModel sends a new update.<strong>ViewController</strong> is responsible for setting up UI views. There is no direct interaction between the ViewController &amp; Model. It should go through ViewModel and request for what it requires in a ready-to-display format. <strong>ViewModel</strong> is responsible for all business logic. The ultimate goal of MVVM is to isolate the UI logic responsibility of ViewController to ViewModel.</p><p>In addition, ViewModel hides data preparation code for visual presentation, asynchronous networking code as well as code listening for model updates. When the ViewModel needs to communicate anything to the View, it will accomplish this with data bindings.</p><p><strong>Benefits of MVVM: </strong>Enhanced Testability — View and Controllers are difficult to test because of its association to the view layer. By moving data manipulation to the ViewModel, MVVM makes the testing much easier. Unit testing of ViewModel is easy now, as it doesn’t have any reference to the object it’s maintained by. Similarly, testing ViewController also becomes easy since it no longer depends on the Model.</p><p>Transparent Communication — The ViewModel offers a transparent interface to the ViewController that it uses to interact with the model and view layers. This results in a transparent communication between the layers of the applications.</p><p>MVVM is an excellent design pattern, which reduces the amount of code on the Views and keeps the code clean, reusable, maintainable and testable.</p><p><strong>Explain the MVC Architecture?</strong></p><p>MVC (Model-View-Controller), is a software architecture for developing iOS apps. It’s one of iOS app development’s fundamental concepts.</p><p>Multiple iOS frameworks use the MVC.</p><p>Categories: <strong>Model:</strong> A model represents the app’s data. It stores info, such as products in a store. A model manages the state of the application.</p><p><strong>View:</strong> A view is responsible for showing and interacting with the UI. For example, a view renders a table of products for your app’s user.</p><p><strong>Controller:</strong> The controller is what glues the model and the view. It’s responsible for controlling the logic that goes between the two.</p><p><strong>What is Closure?</strong></p><p>Closure is a self contained block of functionality that can be passed around and used in code. <strong>There are two kinds of closures:</strong></p><p>An <strong>escaping closure</strong> is a closure that’s called after the function it was passed to returns. In other words, it outlives the function it was passed to.(we can capture outside the function, Closure can be stored somewhere that will be retained after the calling function has finished executing)</p><p>A <strong>non-escaping closure</strong> is a closure that’s called within the function it was passed into, i.e. before it returns(The scope will be limited within the function.The cannot return finish executing after the body of the calling function has returned.</p><p><strong>What are generics and which problem do they solve?</strong></p><p>In Swift, you can use generics in both functions and data types, e.g. in classes, structures or enumerations.</p><p>Generics solve the problem of code duplication. When you have a method that takes one type of parameter, it’s common to duplicate it to accommodate a parameter of a different type.</p><p>For example, in the following code the second function is a “clone” of the first, except it accepts strings instead of integers.</p><p>func areIntEqual(_ x: Int, _ y: Int) -&gt; Bool {</p><p>return x == y</p><p>}</p><p>func areStringsEqual(_ x: String, _ y: String) -&gt; Bool {</p><p>return</p><p>areSl(“Swift”, “Swift”) // true</p><p>areIntEqual(1, 1) // true</p><p><strong>By adopting generics, you can combine the two functions into one and keep type safety at the same time. Here’s the generic implementation:</strong></p><p>func areTheyEqual&lt;T: Equatable&gt;(_ x: T, _ y: T) -&gt; Bool {</p><p>return x == y</p><p>}</p><p>areTheyEqual(“Swift”, “Swift”)</p><p>areTheyEqual(1, 1)</p><p><strong>Since you’re testing equality in this case, you restrict the parameters to any type that implements the </strong><strong>Equatable protocol. This code achieves the intended result and prevents passing parameters of a different type.</strong></p><p><strong>What Are Extensions?</strong></p><p>In Swift, you can use extensions to add functionality to an existing type. In Swift, you can create an extension by using the <strong>extension</strong> keyword:</p><p><strong>extension</strong> SomeExistingType {</p><p>// add new functionality here</p><p>}</p><p><strong>What Is Force Unwrapping? When Should You Use It?</strong></p><p>Force unwrapping<strong> </strong>tries to<strong> </strong>convert an optional to a value regardless of it contains a value or not.</p><p>Force unwrapping is unsafe because if the optional is nil and you try to unwrap it, it triggers an error that crashes the app. Thus, it should be avoided unless you’re 100% sure the optional is not nil.</p><p><strong>Fileprivate vs Private?</strong></p><p>A fileprivate property can be read anywhere in the same Swift file but not outside of it.</p><p>A private property can only be read inside the type in which it was declared (as well as in the extensions of that type in the same file).</p><p><strong>What Are Lazy Variables? When Should You Use One?</strong></p><p>A lazy variable‘s initial value is computed when calling it for the first time. Lazy variables can be used to optimize code by not doing unnecessary work before needed.</p><p>For example:</p><p><strong>lazy</strong> <strong>var</strong> tallest: Person? = {<br> <strong>return</strong> people.max(by: { $0.height &lt; $1.height })<br> }()</p><p><strong>What Is an In-Out Parameter in Swift?</strong></p><p>An <a href="https://www.codingem.com/2021/04/07/swift-what-is-inout/">inout</a> parameter allows you to change the value of a parameter inside the function. To make a parameter in-out, use the inout keyword in front of the parameter type.</p><p>To pass a variable as an in-out, use &amp; in front of its name.</p><p>For example:</p><p><strong>func change(_ number: inout Int){</strong></p><p><strong>number = 12</strong></p><p><strong>}</strong></p><p><strong>var number = 1</strong></p><p><strong>change(&amp;number)</strong></p><p><strong>print(number)</strong></p><p><strong>// Output:</strong></p><p><strong>// 12</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cd84e1793ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top iOS interview questions and answers 2022]]></title>
            <link>https://medium.com/@sunee.ragu/top-ios-interview-questions-and-answers-2022-5f06de9453c1?source=rss-2ffb6e233cac------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f06de9453c1</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[2022]]></category>
            <category><![CDATA[top-5]]></category>
            <category><![CDATA[frequent]]></category>
            <category><![CDATA[ios-interview-question]]></category>
            <dc:creator><![CDATA[Sunee Ragu]]></dc:creator>
            <pubDate>Sun, 25 Sep 2022 17:40:19 GMT</pubDate>
            <atom:updated>2022-09-25T17:40:19.421Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>1. What is the Difference Between Structures and Classes?</strong></h3><p>One of the most important differences between structures and classes is that structures are value types and are always copied when they are passed around in your code, and classes are reference type and are passed by reference.</p><p>classes have Inheritance which allows one class to inherit the characteristics of another.</p><p>Struct properties are stored on Stack and Class instances are stored on Heap, the stack is faster than a class.</p><p>Struct gets a default initializer automatically whereas in Class, we have to initialize.</p><p>Struct is thread safe or singleton at any point of time.</p><p>To summarize the difference between structs and classes, it is necessary to understand the difference between value and reference types.</p><ol><li>When you make a copy of a value type, it copies all the data from the thing you are copying into the new variable. They are 2 separate things and changing one does not affect the other.</li><li>When you make a copy of a reference type, the new variable refers to the same memory location as the thing you are copying. This means that changing one will change the other since they both refer to the same memory location. The sample code below could be taken as reference.</li></ol><h3><strong>2. Storyboard Vs Programmatically creating UI for iOS</strong></h3><p><strong>1. Ease of use</strong></p><p>Storyboards are straight-forward and easy to use. For example, If I needed to create a new view controller with buttons, labels, textfields, or segues, it is fairly easy to implement. With a few clicks, drag, and drop. For programmatically creating a new view needed to write more lines of code. this can get quite tedious. It is important to include translatesAutoresizingMaskIntoConstraints and .active = true , or view will not show.</p><p><strong>2. Visual</strong></p><p>One of the major advantage of using storyboard is that it gives you a very good visual representation of the application. You know how every button, label, textfields, and view will look like. With a few clicks and adjustment, can easily create a whole view.You know how every button, label, textfields, and view will look like. With a few clicks and adjustment, can easily create a whole view. Additionally constraints are visually presented as well, any adjustment to constraints will show in a different color.</p><p><strong>Programmatic</strong></p><p><strong>1. Control</strong></p><p>Coding all of your UI elements will give a sense of control. Anything that is achievable through StoryBoard, can do the same through code. For example if I decided to make one of my font bold. It is easy to change settings in code I know exactly where I placed all the UI elements.</p><p><strong>2. Reusability</strong></p><p>Can reuse the codes throughout our project. If I wanted to create labels inside my view, I can just copy most of that code, and make a few minor adjustments.</p><p><strong>3. Clutter and Navigation</strong></p><p>In Storyboard’s initial phase, this might not seem to be a problem, but once it’s filled with UI elements and controllers, it is very difficult to navigate.</p><p><strong>4. Merge Conflict</strong></p><p>When we are working in a team with other developers, complications starts to arise when we decided to merge our work on GitHub. It is very difficult to resolved the merge conflict. It is not a simple task because our Storyboard merge conflicts consists more than just code, there are codes that renders the UI.</p><h3><strong>3. Data Persistance iOS</strong></h3><p>Different types of data can be saved to the device locally, using different tools (Swift APIs). To achieve that in Swift that we can use</p><p>· UserDefaults</p><p>· Keychain</p><p>· Saving files to disk(FileManager)</p><p>· Core Data</p><p>· SQLite</p><p>· Property Lists(Plist)</p><p><strong>UserDefaults</strong> to store small pieces of information(e.g. whether the user prefers light or dark mode, at what time they want to receive a daily reminder, whether they actually want to receive notifications, etc.). UserDefaults can be retrieved by using the standard static property, a singleton that gives easy access to this storage device.UserDefaults work as a key-value storage, with Strings as keys.</p><p><strong>Keychain u</strong>sed when you need to save sensitive user data, such as passwords or login credentials. Apple Keychain is a very popular and functional Swift tool that every iOS and MacOS user is using. It can be used to save passwords, secure notes, certificates, etc. In general, Keychain is an encrypted database with quite a complicated and robust API.</p><p><strong>Saving files to disk(FileManager) </strong>Apple makes writing, reading, and editing files inside the iOS applications very easy. Every application has a sandbox directory where you can store your files. FileManager object provides all these functionalities with very simple APIs. <strong>Files</strong> can be stored inside catalogs and sub-catalogs of your app’s <em>Document</em> directory. That’s why Apple recommends using the URL to specify and work with files using the <em>FileManager</em> object. URL classes, in general, are used when working with a network like API requests and opening the websites.</p><p><strong>Core data</strong> is one of the most powerful framework provided by Apple for macOS and iOS apps. Core data is used for handling the model layer object in our application. Can treat core data as a framework to filter, modify,, save, track the data within the iOS apps. Core data is not a relational database. Using core data, we can easily map the objects in our app to the table records in the database.</p><p><strong>SQLite</strong> is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. SQLite is a relational database management system. SQLite is not a client-server database engine. In fact, it is embedded in the client application itself. So there is no networking involved in SQLite.</p><p><strong>Property list (Plists) in Swift : </strong><em>Plist</em> files enable storing serialized objects with key/value conventions. In macOS and iOS applications, the most common usage example of plist is an <em>Info.plist</em> file which stores application settings values. Inside <em>Info.plist</em> we can find the application name, bundle identifier, version number, required permissions info, Facebook App info, etc.</p><h3>4. <strong>What are generics and which problem do they solve?</strong></h3><p>In Swift, you can use generics in both functions and data types, e.g. in classes, structures or enumerations. Generics solve the problem of code duplication. When you have a method that takes one type of parameter, it’s common to duplicate it to accommodate a parameter of a different type.</p><p>For example:</p><p>func areIntEqual(_ x: Int, _ y: Int) -&gt; Bool {</p><p>return x == y</p><p>}</p><p>func areStringsEqual(_ x: String, _ y: String) -&gt; Bool {</p><p>return</p><p>areStringsEqual(“iOS”, “iOS”) // true</p><p>areIntEqual(1, 1) // true</p><p>By adopting generics, you can combine the two functions into one and keep type safety at the same time. Here’s the generic implementation:</p><p>func areTheyEqual&lt;T: Equatable&gt;(_ x: T, _ y: T) -&gt; Bool {</p><p>return x == y</p><p>}</p><p>areTheyEqual(“iOS”, “iOS””)</p><p>areTheyEqual(1, 1)</p><p>Since you’re testing equality in this case, you restrict the parameters to any type that implements the Equatable protocol. This code achieves the intended result and prevents passing parameters of a different type.</p><h3><strong>5. Describe screen life cycle?</strong></h3><p>iOS calls the UIViewController methods as follows:</p><p><strong>viewDidLoad() —</strong></p><p>Called when the view controller’s content view (the top of its view hierarchy) is created and loaded from a storyboard. The view controller’s outlets are guaranteed to have valid values by the time this method is called.</p><p><strong>viewWillAppear()</strong> —</p><p>Called just before the view controller’s content view is added to the app’s view hierarchy. Use this method to trigger any operations that need to occur before the content view is presented onscreen.</p><p><strong>viewDidAppear()</strong> —</p><p>Called just after the view controller’s content view has been added to the app’s view hierarchy. Use this method to trigger any operations that need to occur as soon as the view is presented onscreen, such as fetching data or showing an animation.</p><p><strong>viewWillDisappear()</strong> —</p><p>Called just before the view controller’s content view is removed from the app’s view hierarchy. Use this method to perform cleanup tasks like committing changes or resigning the first responder status.</p><p><strong>viewDidDisappear()</strong> —</p><p>Called just after the view controller’s content view has been removed from the app’s view hierarchy. Use this method to perform additional teardown activities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f06de9453c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>