<?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 Veerendra Pratap Singh on Medium]]></title>
        <description><![CDATA[Stories by Veerendra Pratap Singh on Medium]]></description>
        <link>https://medium.com/@veersr9?source=rss-4b44e9afbd94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*I3wnpi-YJincwD3p</url>
            <title>Stories by Veerendra Pratap Singh on Medium</title>
            <link>https://medium.com/@veersr9?source=rss-4b44e9afbd94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:02:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@veersr9/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[SwiftUI Property Wrappers Explained (In the Simplest Way)]]></title>
            <link>https://medium.com/@veersr9/swiftui-property-wrappers-explained-in-the-simplest-way-0a2fd51f9012?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a2fd51f9012</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Tue, 03 Feb 2026 11:43:52 GMT</pubDate>
            <atom:updated>2026-02-03T11:45:34.549Z</atom:updated>
            <content:encoded><![CDATA[<p>SwiftUI uses something called <strong>property wrappers</strong>.<br>At first, they look scary: @State, @Binding, @EnvironmentObject… 🤯</p><p>But don’t worry — once you understand <strong>what problem each one solves</strong>, SwiftUI becomes <em>easy and fun</em>.</p><p>In this article, I’ll explain the most commonly used SwiftUI property wrappers <strong>as simply as possible</strong>, with <strong>small examples.</strong></p><p><strong>No complex theory. No confusion. Just clarity</strong></p><h3>1:- @State – Local State (Only for This View)</h3><p>Use @State when <strong>a value belongs to this view only</strong>.</p><p>Think of it as:</p><blockquote><em>“This view owns this data.”</em></blockquote><h4><strong>Example</strong></h4><pre>struct CounterView: View {<br>    @State private var count = 0<br><br>    var body: some View {<br>        Button(&quot;Count: \(count)&quot;) {<br>            count += 1<br>        }<br>    }<br>}</pre><h3>Easy Explanation</h3><ul><li>count is stored <strong>inside this view</strong></li><li>When count changes → UI updates automatically</li><li>Use @State for <strong>simple values</strong> (Bool, Int, String)</li></ul><h3>2:- @Binding – Sharing State Between Views</h3><p>Use @Binding when <strong>a child view needs to change parent data</strong>.</p><p>Think of it as:</p><blockquote><em>“I don’t own this value, I’m borrowing it.”</em></blockquote><h4>Example</h4><pre>struct ParentView: View {<br>    @State private var isOn = false<br><br>    var body: some View {<br>        ToggleView(isOn: $isOn)<br>    }<br>}<br><br>struct ToggleView: View {<br>    @Binding var isOn: Bool<br><br>    var body: some View {<br>        Toggle(&quot;Switch&quot;, isOn: $isOn)<br>    }<br>}</pre><h3>Easy Explanation</h3><ul><li>Parent owns the data (@State)</li><li>Child modifies it using @Binding</li><li>$ means <em>two-way connection</em></li></ul><h3>3:- @ObservedObject – External Data (Not Owned)</h3><p>Use @ObservedObject when <strong>the view depends on a class object</strong>, but <strong>doesn’t create it</strong>.</p><h4>Example</h4><pre>class CounterModel: ObservableObject {<br>    @Published var count = 0<br>}<br><br>struct CounterView: View {<br>    @ObservedObject var model: CounterModel<br><br>    var body: some View {<br>        Text(&quot;Count: \(model.count)&quot;)<br>    }<br>}</pre><h3>Easy Explanation</h3><ul><li>The view <strong>observes changes</strong></li><li>The object lives <strong>outside</strong></li><li>View refreshes when data changes</li></ul><h3>4:- @StateObject – External Data (Owned by View)</h3><p>Use @StateObject when <strong>this view creates and owns the object</strong>.</p><h4>Example</h4><pre>struct CounterView: View {<br>    @StateObject private var model = CounterModel()<br><br>    var body: some View {<br>        Text(&quot;Count: \(model.count)&quot;)<br>    }<br>}</pre><h3>Easy Explanation</h3><ul><li>View creates the object</li><li>Object lives as long as view lives</li><li>Prevents unwanted re-creation</li></ul><p>— <strong>Rule</strong></p><ul><li>Create object → @StateObject</li><li>Receive object → @ObservedObject</li></ul><h3>5:- @Published – Notify UI About Changes</h3><p>Used <strong>inside a class</strong> to tell SwiftUI:</p><blockquote><em>“Hey, my value changed!”</em></blockquote><h4>Example</h4><pre>class UserModel: ObservableObject {<br>    @Published var name = &quot;John&quot;<br>}</pre><h3>Easy Explanation</h3><ul><li>When name changes</li><li>Any observing view updates automatically</li></ul><h3>6:- @EnvironmentObject – Shared Global Data</h3><p>Use this when <strong>many screens need the same data</strong>.</p><h4>Example</h4><pre>class UserSession: ObservableObject {<br>    @Published var isLoggedIn = false<br>}</pre><pre>@main<br>struct MyApp: App {<br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>                .environmentObject(UserSession())<br>        }<br>    }<br>}</pre><pre>struct ContentView: View {<br>    @EnvironmentObject var session: UserSession<br>}</pre><h3>Easy Explanation</h3><ul><li>No need to pass data again and again</li><li>Perfect for login state, themes, settings</li></ul><p><strong>Warning:</strong> The app will crash if the object is not injected.</p><h3>7:- @Environment – System Values</h3><p>Use this to read <strong>system-provided values</strong>.</p><h4>Example</h4><pre>@Environment(\.dismiss) var dismiss</pre><pre>Button(&quot;Close&quot;) {<br>    dismiss()<br>}</pre><h3>Common Uses</h3><ul><li>dismiss</li><li>colorScheme</li><li>scenePhase</li></ul><h3>8:- @AppStorage – UserDefaults Made Easy</h3><p>Use this to store <strong>small persistent data</strong>.</p><h4>Example</h4><pre>@AppStorage(&quot;isDarkMode&quot;) var isDarkMode = false</pre><h3>Easy Explanation</h3><ul><li>Automatically saved</li><li>Automatically loaded</li><li>No UserDefaults code needed</li></ul><p>Perfect for settings, onboarding flags.</p><h3>9:- @SceneStorage – Temporary State Per Scene</h3><p>Similar to @State, but survives <strong>app backgrounding</strong>.</p><h4>Example</h4><pre>@SceneStorage(&quot;text&quot;) var text = &quot;&quot;</pre><h4>Easy Explanation</h4><ul><li>Data survives app minimization</li><li>Cleared when app fully closes</li></ul><h3>10:- @FetchRequest – Core Data Fetching</h3><p>Used with <strong>Core Data</strong>.</p><h4>Example</h4><pre>@FetchRequest(<br>    entity: Task.entity(),<br>    sortDescriptors: []<br>) var tasks: FetchedResults&lt;Task&gt;</pre><h3>Easy Explanation</h3><ul><li>Automatically fetches data</li><li>Updates UI when database changes</li></ul><h3>11:- @GestureState – Gesture Temporary State</h3><p>Used for gestures like drag, swipe, zoom.</p><h4>Example</h4><pre>@GestureState private var dragOffset = CGSize.zero</pre><h4><strong>Easy Explanation</strong></h4><ul><li>Resets automatically when gesture ends</li><li>Perfect for animations</li></ul><h3>12:- @Namespace – Matched Geometry Animations</h3><p>Used for smooth animations between views.</p><h4>Example</h4><pre>@Namespace private var animation</pre><h3>Easy Explanation</h3><ul><li>Makes animations feel magical</li><li>Used in matchedGeometryEffect</li></ul><h3>13:- @ScaledMetric – Dynamic Type Support</h3><p>Automatically scales values for accessibility.</p><h4>Example</h4><pre>@ScaledMetric var iconSize: CGFloat = 24</pre><h4>Easy Explanation</h4><ul><li>Adjusts for user font size settings</li><li>Helps accessibility</li></ul><h3>14:- @FocusedValue &amp; @FocusedBinding</h3><p>Used for <strong>keyboard focus and commands</strong>.</p><h4>Example</h4><pre>@FocusedBinding(\.focusedField) var text</pre><h3>Easy Explanation</h3><ul><li>Helps manage keyboard focus</li><li>Mostly used in forms and editors</li></ul><h3>15:- @UIApplicationDelegateAdaptor</h3><p>Used when you need <strong>old AppDelegate features</strong> in SwiftUI.</p><h4>Example</h4><pre>@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate</pre><h3>Easy Explanation</h3><ul><li>For notifications</li><li>App lifecycle events</li><li>Legacy SDKs</li></ul><h3>16:- @NSApplicationDelegateAdaptor (macOS)</h3><p>Same as above, but for <strong>macOS apps</strong>.</p><h3><strong>Final Mental Model</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*km2VoYhLNRuY2zaK_mCBDg.png" /></figure><h3><strong>Sample Project — Coming Soon 🙃</strong></h3><h3>✨ Final Thoughts</h3><p>SwiftUI looks confusing <strong>only until you understand ownership</strong>.</p><p>Ask yourself:</p><blockquote><em>Who owns this data?</em></blockquote><p>That one question solves <strong>90% of confusion</strong>.</p><p>If this article helped you, give it a clap 👏<br>Happy coding 😉✌️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a2fd51f9012" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS 26 Liquid Glass in SwiftUI: A Practical Reference + Demo App (LiquidGlassReference)]]></title>
            <link>https://medium.com/@veersr9/ios-26-liquid-glass-in-swiftui-a-practical-reference-demo-app-liquidglassreference-69b8d46dc055?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/69b8d46dc055</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[liquid-glass]]></category>
            <category><![CDATA[glass-effect]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Fri, 26 Dec 2025 11:35:07 GMT</pubDate>
            <atom:updated>2025-12-26T11:48:26.120Z</atom:updated>
            <content:encoded><![CDATA[<p>Apple introduced <strong>Liquid Glass</strong> as the new navigation-layer material system across iOS 26 and other platforms. It’s not just “blur” — it’s a dynamic material that responds to content, motion, and interaction, giving UI controls a floating, physical feel.</p><p>In this post, I’ll share:</p><ul><li>What Liquid Glass is (in practical terms)</li><li>Where to use it (and where NOT to)</li><li>The key SwiftUI APIs you’ll use daily</li><li>A working demo project: <strong>LiquidGlassReference</strong> (playground-style app)</li></ul><h3>What Liquid Glass is (the developer view)</h3><p>Liquid Glass is designed for the <strong>navigation layer</strong> — controls that float above content:</p><p><strong>Correct:-</strong> Tab bars, toolbars, floating action buttons, menus, sheets<br><strong>Wrong:- </strong>Content cells, lists, media, long scrolling content, “glass everywhere”</p><p>The goal is hierarchy:</p><ul><li><strong>Content</strong> stays clean and readable</li><li><strong>Controls</strong> float above content with glass depth + interaction</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*J0aQas9yDw6AFKdyyT4YBA.gif" /></figure><h3>1) The core API: glassEffect</h3><p>The simplest usage:</p><pre>Text(&quot;Hello, Liquid Glass&quot;)<br>    .padding()<br>    .glassEffect(.regular, in: .capsule)</pre><p>In iOS 26, you’ll mainly work with:</p><ul><li>.regular → default general-purpose glass</li><li>.clear → high transparency for media-heavy backgrounds (use carefully)</li><li>.identity → “off” / no glass (use this to disable)</li></ul><h3>2) Interactive glass: .interactive()</h3><p>The interactive modifier gives that “alive” feeling:</p><ul><li>press scaling</li><li>bounce</li><li>shimmer-like response</li><li>touch illumination</li></ul><pre>Button(&quot;Tap Me&quot;) { }<br>    .glassEffect(.regular.interactive(), in: .capsule)</pre><p>Tip: use interactive glass for <strong>primary floating controls</strong> (FAB, quick actions), not for every button.</p><h3>3) Performance rule: always use GlassEffectContainer</h3><p>When you have multiple glass elements together, wrap them in a container:</p><pre>GlassEffectContainer {<br>    HStack(spacing: 12) {<br>        Button { } label: { Image(systemName: &quot;pencil&quot;) }<br>            .buttonStyle(.glass)<br><br>        Button { } label: { Image(systemName: &quot;trash&quot;) }<br>            .buttonStyle(.glass)<br>    }<br>}</pre><p>This matters because glass sampling is expensive and glass shouldn’t “sample glass”.</p><h3>4) Morphing transitions: glassEffectID</h3><p>If you want Apple-style morphing between states (like expanding action clusters), use:</p><ul><li>GlassEffectContainer</li><li>a shared @Namespace</li><li>glassEffectID(...)</li><li>animations on state change</li></ul><pre>@State private var expanded = false<br>@Namespace private var ns<br><br>GlassEffectContainer(spacing: 18) {<br>    Button {<br>        withAnimation(.bouncy(duration: 0.35)) {<br>            expanded.toggle()<br>        }<br>    } label: {<br>        Image(systemName: expanded ? &quot;xmark&quot; : &quot;plus&quot;)<br>            .frame(width: 56, height: 56)<br>    }<br>    .buttonStyle(.glassProminent)<br>    .buttonBorderShape(.circle)<br>    .clipShape(Circle())<br>    .glassEffectID(&quot;toggle&quot;, in: ns)<br><br>    if expanded {<br>        Button(&quot;Action&quot;) { }<br>            .buttonStyle(.glass)<br>            .glassEffectID(&quot;action&quot;, in: ns)<br>            .glassEffectTransition(.materialize)<br>    }<br>}</pre><p>This is the pattern that makes Liquid Glass feel “native”.</p><h3>5) glassEffectUnion (manual grouping for distant controls)</h3><p>Sometimes controls are too far apart to morph naturally. glassEffectUnion lets you visually group them even with distance:</p><pre>@Namespace private var ns<br><br>GlassEffectContainer {<br>    Button(&quot;Edit&quot;) { }<br>        .buttonStyle(.glass)<br>        .glassEffectUnion(id: &quot;tools&quot;, namespace: ns)<br><br>    Spacer().frame(height: 80)<br><br>    Button(&quot;Delete&quot;) { }<br>        .buttonStyle(.glass)<br>        .glassEffectUnion(id: &quot;tools&quot;, namespace: ns)<br>}</pre><h3>6) TabView extras and bottom accessory</h3><p>With iOS 26, TabView gained extra behaviors (depending on SDK builds). A practical pattern is a “Now Playing” accessory view above the tab bar:</p><pre>TabView {<br>    // tabs...<br>}<br>.tabViewBottomAccessory {<br>    HStack {<br>        Image(systemName: &quot;music.note&quot;)<br>        Text(&quot;Now Playing&quot;)<br>        Spacer()<br>        Button { } label: { Image(systemName: &quot;play.fill&quot;) }<br>            .buttonStyle(.glass)<br>    }<br>    .padding()<br>}</pre><p>Note: APIs and environment values can vary slightly across betas, so keep this behind #available(iOS 26.0, *).</p><h3>7) Clear glass needs extra care (readability)</h3><p>.clear looks beautiful over images and video—but readability can suffer. In the demo app, I added a simple optional dimming layer:</p><pre>ZStack {<br>    backgroundImage<br><br>    Color.black.opacity(0.25) // subtle dim<br>        .ignoresSafeArea()<br><br>    controls<br>        .glassEffect(.clear, in: .capsule)<br>}</pre><p>This keeps text and icons readable on busy backgrounds.</p><h3>LiquidGlassReference Demo App (what’s included)</h3><p>The <strong>LiquidGlassReference</strong> sample project is structured as a real developer playground:</p><h3>- Tabs</h3><ul><li><strong>Home</strong>: Floating morphing cluster + union demo + toolbar + sheet</li><li><strong>Playground</strong>: switch Regular/Clear/Off + toggle Interactive + Tint + shapes</li><li><strong>Search</strong>: searchable demo screen</li><li><strong>Settings</strong>: global toggles that affect all UI</li></ul><h3>- Includes a compatibility helper</h3><p>A small helper that uses iOS 26 glass, and falls back to ultraThinMaterial on older iOS versions, so you can keep the project flexible.</p><h4><strong>Demo Project</strong>:- <a href="https://github.com/veersr9/Liquid-Glass-Reference">LiquidGlassReference</a></h4><h3>Best practices I follow</h3><ul><li>Use Liquid Glass for <strong>navigation</strong>, not content</li><li>Use GlassEffectContainer whenever multiple glass elements exist</li><li>Prefer .regular most of the time</li><li>Use .clear only over media backgrounds + consider a dim layer</li><li>Don’t animate glass continuously (thermal + battery impact)</li><li>Test on older devices and with accessibility modes</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69b8d46dc055" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AppStore-Style iOS Tab Bar Sample — Liquid Glass Bubble TabBar + Floating Chat Button…]]></title>
            <link>https://medium.com/@veersr9/appstore-style-ios-tab-bar-sample-liquid-glass-bubble-tabbar-floating-chat-button-2d8a726145cf?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d8a726145cf</guid>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[ios-26]]></category>
            <category><![CDATA[tab-bar]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[apple-liquid-glass]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Fri, 26 Dec 2025 09:43:18 GMT</pubDate>
            <atom:updated>2025-12-26T09:43:18.546Z</atom:updated>
            <content:encoded><![CDATA[<h3>AppStore-Style iOS Tab Bar Sample — Liquid Glass Bubble TabBar + Floating Chat Button (FullScreenCover) + iOS 26 Action Tab</h3><p>AppStore-Style iOS Tab Bar Sample — Liquid Glass Bubble TabBar + Floating Chat Button (FullScreenCover) + iOS 26 Action Tab</p><p>This project focuses on two things developers usually struggle with:</p><p><strong>1:- This project focuses on three things developers usually struggle with:<br>2:- Floating Chat Button (Always visible)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*C7uqITttkspSdyglqCjfKQ.gif" /></figure><h3>iOS 26 Bonus: System TabBar + Action Tab (Chat)</h3><p>For iOS 26, the sample also includes a <strong>System TabBar implementation</strong> using the newer Tab(...) API.</p><p>The last tab behaves like an <strong>action button</strong>:</p><ul><li>User taps “More/Chat”</li><li>It <strong>does not navigate to a new tab</strong></li><li>Instead, it <strong>opens chat full screen</strong></li><li>Then it <strong>reverts back</strong> to the previously selected tab</li></ul><p>This pattern is perfect for “Share”, “More”, “Create”, or “Chat” actions.</p><h3>Who should use this?</h3><ul><li>iOS developers building modern SwiftUI apps</li><li>Anyone who wants an <strong>AppStore-like tab bar animation</strong></li><li>Apps with quick actions like <strong>Chat / Share / Create</strong> in the tab area</li><li>Teams that need a <strong>ready-to-share reference project</strong> for consistent UI implementation</li></ul><p>Sample Project Link:- <a href="https://github.com/veersr9/AppStore-Tabbar/"><strong>AppStore Tabbar</strong></a></p><p>SwiftUI, iOS TabBar, AppStore TabBar, Bubble TabBar, Liquid Glass, Custom TabBar, Floating Button, FullScreenCover, iOS 26 TabView, Action Tab, SwiftUI Animation, iOS UI, TabBar Design</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d8a726145cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install FFmpeg]]></title>
            <link>https://medium.com/@veersr9/how-to-install-ffmpeg-e0b4e1cf2af9?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0b4e1cf2af9</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 13:00:30 GMT</pubDate>
            <atom:updated>2025-06-06T13:00:30.663Z</atom:updated>
            <content:encoded><![CDATA[<h4>For macOS (using Homebrew — Recommended)</h4><p>If you don’t have Homebrew installed, install it first:</p><pre>/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;</pre><p>Then install FFmpeg:</p><pre>brew install ffmpeg</pre><p>You can verify the installation with:</p><pre>ffmpeg -version</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0b4e1cf2af9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete Guide Playing Audio, Video & Subtitles with master.m3u8 (HLS)]]></title>
            <link>https://medium.com/@veersr9/complete-guide-playing-audio-video-subtitles-with-master-m3u8-hls-090cdcdc1141?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/090cdcdc1141</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[m3u8]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 12:58:25 GMT</pubDate>
            <atom:updated>2025-06-06T13:03:05.765Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>For weeks, I struggled with combining separate video, audio, and subtitle files into a single HLS (.m3u8) stream that works in Safari and iOS apps. Despite everything looking correct, nothing would play — the infamous crossed-out play icon was all I saw. If you’ve been there, this post is for you.</p><p>This blog walks through the full working solution, including FFmpeg commands, file structure, and how to test with a local web server.</p><h3>The Problem</h3><p>I had:</p><ul><li>A .mp4 file for video</li><li>B .mp3 file for audio</li><li>C .vtt file for subtitles</li></ul><p>All files worked fine separately. But combining them into a working .m3u8 setup was another story. I tried different playlist structures, manually editing .m3u8 files, and debugging AVPlayer — all with no success.</p><h3>The Working Solution (Step-by-Step)</h3><h4>Step 1: Merge the media using FFmpeg (<a href="https://medium.com/@veersr9/how-to-install-ffmpeg-e0b4e1cf2af9">How to Install FFmpeg</a>)</h4><p>Use FFmpeg to merge your .mp4, .mp3, and .vtt into HLS-compliant .ts chunks and playlists.</p><pre>ffmpeg -i video.mp4 -i audio.mp3 -i subtitles.vtt \<br>  -c:v copy -c:a aac -c:s webvtt \<br>  -map 0:v -map 1:a -map 2:s \<br>  -f hls \<br>  -hls_time 10 \<br>  -hls_list_size 0 \<br>  -hls_segment_filename &quot;segment_%03d.ts&quot; \<br>  playlist.m3u8</pre><h4>Step 2: Create the master.m3u8 file</h4><p>This is the top-level playlist referencing your audio/video and subtitles.</p><pre>#EXTM3U<br>#EXT-X-VERSION:3<br><br># Subtitles<br>#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=&quot;subs&quot;,NAME=&quot;English&quot;,LANGUAGE=&quot;en&quot;,DEFAULT=YES,AUTOSELECT=YES,URI=&quot;playlist_subtitles.m3u8&quot;<br><br># Combined stream<br>#EXT-X-STREAM-INF:BANDWIDTH=1200000,RESOLUTION=640x360,SUBTITLES=&quot;subs&quot;<br>playlist.m3u8</pre><h4>Serve using a local web server</h4><p>HLS playback needs proper HTTP serving, not just local file access. Run this in the folder where your files are:<br><strong>Important:- </strong>.m3u8 this file will not run with this local path (file://) that&#39;s why we create our local server at device.</p><pre>python3 -m http.server 8080</pre><p>Now open http://localhost:8080/master.m3u8 in Safari — it should play with both audio and subtitles!</p><pre>let url = URL(string: &quot;http://localhost:8080/master.m3u8&quot;)!<br>let player = AVPlayer(url: url)<br>let playerViewController = AVPlayerViewController()<br>playerViewController.player = player<br>present(playerViewController, animated: true) {<br>    player.play()<br>}</pre><h3>What If You’re Downloading Files from the Server?</h3><p>If your app receives .mp4, .mp3, and .vtt files from a server:</p><ul><li>You’ll need to run FFmpeg <strong>on the backend</strong> (server-side) to generate the HLS structure.</li><li>Then serve the generated HLS files (including .ts, .vtt, .m3u8) over HTTP.</li><li>The app can then stream them by loading the master.m3u8 URL into AVPlayer.</li></ul><p>If you want to do this client-side (inside the app), you’d need to integrate FFmpeg via frameworks like <a href="https://github.com/tanersener/mobile-ffmpeg">MobileFFmpeg</a>, which can be tricky and is not Apple-approved for App Store distribution.</p><ul><li><strong>Other Solution:</strong> Another solution is also here direct play audio/video and subtitle file <strong>Click Here</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=090cdcdc1141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVC, MVVM, MVP and VIPER design patterns]]></title>
            <link>https://medium.com/@veersr9/mvc-mvvm-mvp-and-viper-design-patterns-e4165c150da9?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4165c150da9</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 12:34:32 GMT</pubDate>
            <atom:updated>2025-06-02T12:35:22.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*vVNgYpJ8KYjy_ETUY1gA8A.gif" /></figure><h3>1. MVC (Model-View-Controller)</h3><blockquote><em>Separates an application into three components:</em></blockquote><ul><li><strong>Model</strong>: Handles the data and business logic.</li><li><strong>View</strong>: Displays UI elements and user interactions.</li><li><strong>Controller</strong>: Connects Model and View, handles user input and updates the View.</li></ul><h3>Example:</h3><p><strong>Model.swift</strong></p><pre>struct User {<br>    let name: String<br>    let age: Int<br>}</pre><p><strong>ViewController.swift (Controller + View)</strong></p><pre>class UserViewController: UIViewController {<br>    let nameLabel = UILabel()<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        let user = User(name: &quot;Alice&quot;, age: 30)<br>        nameLabel.text = &quot;Name: \(user.name)&quot;<br>    }<br>}</pre><h3>2. MVVM (Model-View-ViewModel)</h3><blockquote><em>Introduces a </em><strong><em>ViewModel</em></strong><em> that prepares and manages data for the View:</em></blockquote><ul><li><strong>Model</strong>: Holds data and logic.</li><li><strong>ViewModel</strong>: Transforms model data into a format suitable for the View.</li><li><strong>View</strong>: Observes ViewModel and reflects updates in the UI.</li></ul><h3>Example:</h3><p><strong>Model.swift</strong></p><pre>struct User {<br>    let name: String<br>    let age: Int<br>}</pre><p><strong>UserViewModel.swift</strong></p><pre>class UserViewModel {<br>    private let user: User<br>    <br>    var displayName: String {<br>        return &quot;Name: \(user.name)&quot;<br>    }<br>    <br>    init(user: User) {<br>        self.user = user<br>    }<br>}</pre><p><strong>ViewController.swift</strong></p><pre>class UserViewController: UIViewController {<br>    let nameLabel = UILabel()<br>    var viewModel: UserViewModel!<br><br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        let user = User(name: &quot;Alice&quot;, age: 30)<br>        viewModel = UserViewModel(user: user)<br>        nameLabel.text = viewModel.displayName<br>    }<br>}</pre><h3>3. MVP (Model-View-Presenter)</h3><blockquote><em>Moves presentation logic to a </em><strong><em>Presenter</em></strong><em>:</em></blockquote><ul><li><strong>Model</strong>: Manages the data.</li><li><strong>Presenter</strong>: Contains the UI logic and communicates with the Model and View.</li><li><strong>View</strong>: Passive layer that delegates user interaction to the Presenter.</li></ul><h3>Example:</h3><p><strong>Model.swift</strong></p><pre>struct User {<br>    let name: String<br>}</pre><p><strong>View Protocol</strong></p><pre>protocol UserView: AnyObject {<br>    func showUserName(_ name: String)<br>}</pre><p><strong>Presenter.swift</strong></p><pre>class UserPresenter {<br>    weak var view: UserView?<br>    <br>    func loadUser() {<br>        let user = User(name: &quot;Bob&quot;)<br>        view?.showUserName(user.name)<br>    }<br>}</pre><p><strong>ViewController.swift</strong></p><pre>class UserViewController: UIViewController, UserView {<br>    let nameLabel = UILabel()<br>    var presenter = UserPresenter()<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        presenter.view = self<br>        presenter.loadUser()<br>    }<br><br>    func showUserName(_ name: String) {<br>        nameLabel.text = &quot;User: \(name)&quot;<br>    }<br>}</pre><h3>4. VIPER (View-Interactor-Presenter-Entity-Router)</h3><blockquote><em>A highly modular architecture that splits responsibilities:</em></blockquote><ul><li><strong>View</strong>: Displays data and forwards user input.</li><li><strong>Interactor</strong>: Contains business logic.</li><li><strong>Presenter</strong>: Prepares data for the View.</li><li><strong>Entity</strong>: Plain data model.</li><li><strong>Router</strong>: Handles navigation and routing logic.</li></ul><h3>Example (simplified):</h3><p><strong>Entity.swift</strong></p><pre>struct User {<br>    let name: String<br>}</pre><p><strong>Interactor.swift</strong></p><pre>protocol UserInteractorProtocol {<br>    func fetchUser()<br>}<br><br>class UserInteractor: UserInteractorProtocol {<br>    var presenter: UserPresenterProtocol?<br>    <br>    func fetchUser() {<br>        let user = User(name: &quot;Eve&quot;)<br>        presenter?.didFetch(user: user)<br>    }<br>}</pre><p><strong>Presenter.swift</strong></p><pre>protocol UserPresenterProtocol {<br>    func didFetch(user: User)<br>}<br><br>class UserPresenter: UserPresenterProtocol {<br>    weak var view: UserViewProtocol?<br>    <br>    func didFetch(user: User) {<br>        view?.showUser(name: user.name)<br>    }<br>}</pre><p><strong>ViewController.swift</strong></p><pre>protocol UserViewProtocol: AnyObject {<br>    func showUser(name: String)<br>}<br><br>class UserViewController: UIViewController, UserViewProtocol {<br>    let nameLabel = UILabel()<br>    var interactor: UserInteractorProtocol!<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        interactor.fetchUser()<br>    }<br><br>    func showUser(name: String) {<br>        nameLabel.text = &quot;VIPER: \(name)&quot;<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4165c150da9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Swift Package Manager Is Replacing CocoaPods in Modern iOS Development]]></title>
            <link>https://medium.com/@veersr9/why-swift-package-manager-is-replacing-cocoapods-in-modern-ios-development-92e1382fb390?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/92e1382fb390</guid>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 10:11:12 GMT</pubDate>
            <atom:updated>2025-06-02T10:11:12.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Native Integration in Xcode</h3><ul><li><strong>SwiftPM is built into Xcode</strong> (since Xcode 11).</li><li>No need for external tools like pod install.</li><li>You add dependencies via a Git URL directly in Xcode.</li></ul><blockquote><em>🧠 </em>This reduces complexity and eliminates dependency on Ruby and CocoaPods setup.</blockquote><h3>2. Simpler Dependency Management</h3><ul><li>Swift packages are version-controlled via Git tags.</li><li>No need for .xcworkspace or maintaining a Podfile.lock.</li><li>No risk of breaking changes due to post-install scripts or third-party tooling.</li></ul><h3>3. Lightweight &amp; Fast</h3><ul><li>SwiftPM is <strong>faster and more lightweight</strong> compared to CocoaPods.</li><li>It avoids creating bulky frameworks or modifying your Xcode project file excessively.</li></ul><h3>4. Better for CI/CD</h3><ul><li>SwiftPM doesn’t require pre-install steps or maintaining pod caches.</li><li>CI pipelines become faster and more reliable, especially with GitHub-hosted Swift packages.</li></ul><h3>5. No External Dependencies</h3><ul><li>CocoaPods relies on Ruby, which isn’t pre-installed or actively maintained on all macOS systems anymore.</li><li>SwiftPM uses only Xcode and Swift tools — no need for gem install cocoapods.</li></ul><h3>6. Module Stability &amp; Modern Swift Features</h3><ul><li>Swift packages are more aligned with <strong>module stability</strong>, <strong>binary dependencies</strong>, and <strong>multi-platform support</strong>(macOS, iOS, watchOS, etc.).</li><li>Some libraries now support <strong>only</strong> SwiftPM.</li></ul><h3>When to still consider CocoaPods?</h3><p>You might still use CocoaPods if:</p><ul><li>You rely on libraries that haven’t yet migrated to SwiftPM.</li><li>You have legacy projects or shared pods with complex setups or custom scripts.</li><li>You need Objective-C bridging workarounds that are CocoaPods-specific.</li></ul><h3><strong>Summary</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XANU7rLRd_LbFo0eqaZ8XA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92e1382fb390" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding ARC (Automatic Reference Counting) in Swift — Explained Simply]]></title>
            <link>https://medium.com/@veersr9/understanding-arc-automatic-reference-counting-in-swift-explained-simply-1531502d4477?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/1531502d4477</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 07:43:46 GMT</pubDate>
            <atom:updated>2025-06-02T07:43:46.198Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding ARC (Automatic Reference Counting) in Swift — Explained Simply</h3><p>If you’re coming from languages like JavaScript or Python, you might never have had to think about memory management much. But in Swift, memory management is handled using a concept called <strong>ARC</strong> — <strong>Automatic Reference Counting</strong>.</p><p>Don’t worry, though — it’s not nearly as scary as it sounds. In fact, most of the time, ARC just works in the background. But understanding how it works is <em>super helpful</em> to avoid unexpected bugs, like memory leaks.</p><p>Let’s break it down in plain English, with a simple example.</p><h3>What is ARC?</h3><p>Every time you create an instance of a class in Swift, ARC keeps track of how many <em>strong references</em> are pointing to it.</p><p>When there are <strong>no more references</strong>, ARC automatically deallocates (frees up) that instance from memory.</p><p>Think of it like this:</p><blockquote><em>“I’ll keep this object in memory as long as someone is still using it. If nobody needs it anymore, I’ll clean it up.”</em></blockquote><p>This helps keep your app memory-efficient <strong>without you doing manual cleanup</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-H8EFy3w-D8KMgP6UakwBQ.png" /></figure><h3>Let’s See It In Action</h3><p>Here’s a basic example:</p><pre>class Person {<br>    let name: String<br><br>    init(name: String) {<br>        self.name = name<br>        print(&quot;\(name) is initialized&quot;)<br>    }<br><br>    deinit {<br>        print(&quot;\(name) is deinitialized&quot;)<br>    }<br>}<br><br>var person1: Person? = Person(name: &quot;Alice&quot;)<br>var person2 = person1<br><br>person1 = nil<br>person2 = nil</pre><h3>What’s Happening Here?</h3><ul><li>We create an instance of Person named “Alice”.</li><li>person1 points to Alice. Then person2 also points to the same instance.</li><li>Now, <strong>two references</strong> are holding onto Alice.</li><li>When we set person1 = nil, ARC sees that there’s still person2, so it doesn’t free the memory yet.</li><li>Only when <strong>both references are nil</strong>, ARC says, “Okay, no one needs this anymore,” and deinitializes the object.</li></ul><p>You’ll see this output:</p><pre>Alice is initialized<br>Alice is deinitialized</pre><h3>Why Should You Care?</h3><p>This is where things get important.</p><p>Sometimes, you can create what’s called a <strong>retain cycle</strong> — a situation where two objects hold strong references to each other, so neither gets deallocated. This leads to a <strong>memory leak</strong>.</p><p>Here’s a quick illustration:</p><pre>class Teacher {<br>    var student: Student?<br>}<br><br>class Student {<br>    var teacher: Teacher?<br>}<br><br>var mrSmith: Teacher? = Teacher()<br>var john: Student? = Student()<br><br>mrSmith?.student = john<br>john?.teacher = mrSmith<br><br>mrSmith = nil<br>john = nil</pre><p>You might expect the instances to be deallocated, but they won’t be. Why? Because Teacher holds on to Student, and Student holds on to Teacher.</p><p>ARC sees both objects still have references — even though they’re only referencing each other — and doesn’t clean them up.</p><h3>How to Fix It? Use weak or unowned</h3><p>To break the cycle, we make one of those references <strong>weak</strong>:</p><pre>class Teacher {<br>    var student: Student?<br>}<br><br>class Student {<br>    weak var teacher: Teacher?<br>}</pre><p>Now, Student does not increase the reference count of Teacher. So when you set both mrSmith and john to nil, ARC cleans them up properly.</p><h3>Summary</h3><ul><li>ARC automatically manages memory in Swift.</li><li>It keeps track of <em>strong references</em> and deallocates objects when no one needs them.</li><li>Watch out for <strong>retain cycles</strong> — use weak or unowned to break them.</li><li>You mostly don’t need to do anything — just be careful when two objects reference each other.</li></ul><h3>Quick Tip</h3><p>If you’re ever debugging memory issues in your app, look out for:</p><ul><li>Objects that never get deinitialized.</li><li>Circular references in closures or delegates (often solved with [weak self] in closures).</li></ul><p>Hope this helps you better understand how Swift manages memory under the hood with ARC!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1531502d4477" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protocol Extensions in Swift 6.0: New Powerful Tricks]]></title>
            <link>https://medium.com/@veersr9/protocol-extensions-in-swift-6-0-new-powerful-tricks-50f62879c854?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/50f62879c854</guid>
            <category><![CDATA[extension]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[protocol]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Thu, 29 May 2025 12:35:50 GMT</pubDate>
            <atom:updated>2025-05-30T05:24:37.035Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*T3OJZk-KqLNot4RQZ2AAUQ.png" /></figure><p>Swift 6.0 brings powerful enhancements to <strong>protocol extensions</strong>, making them more expressive, type-safe, and versatile. Here’s a brief overview of the key improvements you need to know:</p><h3>1. Generalized Existentials</h3><p>You can now use <strong>protocols with associated types</strong> and <strong>self requirements</strong> as existentials more freely.</p><pre>protocol Shape {<br>    associatedtype Size<br>    func area() -&gt; Size<br>}<br><br>// Previously, this was not allowed:<br>func printArea(of shape: any Shape) {<br>    // now allowed with Swift 6.0<br>}</pre><p>This enables more flexibility when passing around protocol types with associated types.</p><h3>2. Default Implementations with Where Clauses</h3><p>Swift now allows <strong>more powerful constraints</strong> in protocol extensions.</p><pre>protocol Drawable {<br>    func draw()<br>}<br><br>extension Drawable where Self: UIView {<br>    func draw() {<br>        print(&quot;Drawing a UIView&quot;)<br>    }<br>}</pre><p>This allows tailored default implementations based on conforming type context.</p><h3>3. Improved Type Inference in Extensions</h3><p>Swift 6 improves <strong>type checking and inference</strong>, making code in protocol extensions more predictable and safe.</p><h3>4. Opaque Result Types in Protocol Extensions</h3><p>You can return some Protocol in extension methods to hide concrete types while still conforming to protocols.</p><pre>protocol Generator {<br>    associatedtype Output<br>    func generate() -&gt; Output<br>}<br><br>extension Generator {<br>    func boxed() -&gt; some Generator {<br>        return BoxedGenerator(self)<br>    }<br>}</pre><h3>Enhanced Static Dispatch for Protocol Extensions</h3><p>Performance is improved with <strong>better dispatch optimizations</strong> in protocol extensions, especially when using generic constraints.</p><h3>Summary</h3><ul><li>Use any Protocol more flexibly thanks to Generalized Existentials</li><li>Add powerful constraints with where clauses in protocol extensions</li><li>Return some Protocol types from methods</li><li>Enjoy cleaner, more maintainable, and reusable code</li><li>Gain performance through smarter dispatch</li></ul><h3><strong>Real-World Use Case: Networking with </strong><strong>associatedtype</strong></h3><p>Imagine you’re building a <strong>NetworkService</strong> that fetches different types of data — users, posts, or products. Each request returns a <strong>different data type</strong>, but you want a reusable and type-safe system.</p><p><strong>Step 1: Define a </strong><strong>Request Protocol</strong></p><pre>protocol Request {<br>    associatedtype Output: Decodable<br>    var url: URL { get }<br>}</pre><p>Here:</p><ul><li>Output is the expected response type.</li><li>Each conforming request will define what Output it returns.</li></ul><p><strong>Step 2: Create Specific Requests</strong></p><pre>struct User: Decodable {<br>    let id: Int<br>    let name: String<br>}<br><br>struct GetUserRequest: Request {<br>    typealias Output = User<br>    let url = URL(string: &quot;https://api.example.com/user/1&quot;)!<br>}<br><br>struct GetUsersRequest: Request {<br>    typealias Output = [User]<br>    let url = URL(string: &quot;https://api.example.com/users&quot;)!<br>}</pre><p><strong>Step 3: Generic NetworkService</strong></p><pre>class NetworkService {<br>    func send&lt;T: Request&gt;(_ request: T) async throws -&gt; T.Output {<br>        let (data, _) = try await URLSession.shared.data(from: request.url)<br>        return try JSONDecoder().decode(T.Output.self, from: data)<br>    }<br>}</pre><p>Now you can use this service like this:</p><pre>let service = NetworkService()<br><br>Task {<br>    do {<br>        let user: User = try await service.send(GetUserRequest())<br>        print(&quot;User name: \(user.name)&quot;)<br>        <br>        let users: [User] = try await service.send(GetUsersRequest())<br>        print(&quot;User count: \(users.count)&quot;)<br>    } catch {<br>        print(&quot;Error: \(error)&quot;)<br>    }<br>}</pre><h3>Benefits</h3><ul><li>Clean, reusable structure</li><li>Type-safe decoding with associatedtype</li><li>Easy to add new endpoints (just create a new struct)</li><li>No repeated networking or decoding logic</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50f62879c854" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ What is a Tuple in Swift?]]></title>
            <link>https://medium.com/@veersr9/what-is-a-tuple-in-swift-69ca2d603b27?source=rss-4b44e9afbd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/69ca2d603b27</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[tuples]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Veerendra Pratap Singh]]></dc:creator>
            <pubDate>Thu, 29 May 2025 11:34:00 GMT</pubDate>
            <atom:updated>2025-05-29T11:34:00.730Z</atom:updated>
            <content:encoded><![CDATA[<p>A <strong>tuple</strong> in Swift is a <strong>group of multiple values combined into a single compound value</strong>. These values can be of <strong>different types</strong>.</p><p>You can think of a tuple like a <strong>temporary container</strong> that holds a few related pieces of data — <strong>without needing to create a custom struct or class</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bb2LjOf4iNFecFglPlMIRw.png" /></figure><p>Let’s dive into some perfect examples! 🚀</p><p><strong>Basic Example</strong></p><pre>let person = (&quot;Alice&quot;, 28)<br>print(&quot;Name: \(person.0), Age: \(person.1)&quot;)</pre><p><strong>Output:</strong></p><pre>Name: Alice, Age: 28</pre><p>This tuple holds a <strong>String</strong> and an <strong>Int</strong>. You can access the values using .0, .1, etc.</p><h3><strong>Named Tuples</strong></h3><p>You can also give <strong>names</strong> to the elements in a tuple, which makes your code more readable:</p><p><strong>Basic Example</strong></p><pre>let person = (name: &quot;Bob&quot;, age: 32)<br>print(&quot;Name: \(person.name), Age: \(person.age)&quot;)</pre><p><strong>Output:</strong></p><pre>Name: Bob, Age: 32</pre><h3>Why Use Tuples?</h3><ul><li>Quick and lightweight way to return multiple values from a function.</li><li>Great for short-lived grouped values.</li><li>Avoids creating new data types just for small sets of values.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69ca2d603b27" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>