<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>IOS on Mike Gopsill</title>
    <link>https://www.mikegopsill.com/tags/ios/</link>
    <description>Recent content in IOS on Mike Gopsill</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en</language>
    <lastBuildDate>Fri, 20 Jun 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.mikegopsill.com/tags/ios/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to Control the Status Bar in iOS Simulator</title>
      <link>https://www.mikegopsill.com/posts/control-statusbar-ios-simulator/</link>
      <pubDate>Fri, 20 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/control-statusbar-ios-simulator/</guid>
      <description>&lt;p&gt;Need to quickly change the iOS Simulator&amp;rsquo;s status bar for screenshots or testing? You can do it with the &lt;code&gt;simctl&lt;/code&gt; command-line tool. Here&amp;rsquo;s a quick look.&lt;/p&gt;
&lt;h2 id=&#34;the-basic-command&#34;&gt;The Basic Command&lt;/h2&gt;
&lt;p&gt;The core command to manipulate the status bar is:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;xcrun simctl status_bar &amp;lt;device&amp;gt; override &amp;lt;options&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;device&amp;gt;&lt;/code&gt;: Use &lt;code&gt;booted&lt;/code&gt; for the currently running simulator, or a specific simulator UDID (get a list with &lt;code&gt;xcrun simctl list devices&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;options&amp;gt;&lt;/code&gt;: These are key-value pairs for what you want to change.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;common-status-bar-overrides&#34;&gt;Common Status Bar Overrides&lt;/h2&gt;
&lt;p&gt;Here are some of the most common things you&amp;rsquo;ll want to do:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Searchable Folders in SwiftUI</title>
      <link>https://www.mikegopsill.com/posts/custom-outlinegroup-search/</link>
      <pubDate>Sat, 31 May 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/custom-outlinegroup-search/</guid>
      <description>&lt;p&gt;If you haven’t met &lt;code&gt;OutlineGroup&lt;/code&gt; in SwiftUI yet, picture Finder’s sidebar rendered in SwiftUI: click a chevron, folder children appear. I recently tried to get this working with search. I wanted folders to open and close depending on whether the contained valid results&amp;hellip;&lt;/p&gt;
&lt;p&gt;After much wrestling and many coffees I gave up on &lt;code&gt;OutlineGroup&lt;/code&gt; in favour of a tiny &lt;code&gt;Node&lt;/code&gt; model, a &lt;code&gt;ExplorerStore&lt;/code&gt; viewmodel, and some recursion.&lt;/p&gt;
&lt;p&gt;The result? A searchable file‑browser that behaves at least as my mental model thinks it should.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Stopping SetNSColor(CGContext*, void const*) Crashes in UIKit</title>
      <link>https://www.mikegopsill.com/posts/setnscolor-crash-uikit/</link>
      <pubDate>Fri, 16 May 2025 09:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/setnscolor-crash-uikit/</guid>
      <description>&lt;h2 id=&#34;tldr&#34;&gt;TL;DR&lt;/h2&gt;
&lt;p&gt;I recently encountered a crash on &lt;code&gt;SetNSColor(CGContext*, void const*)&lt;/code&gt; with&lt;br&gt;
&lt;code&gt;[__SwiftValue CGColor]: unrecognized selector sent to instance&lt;/code&gt;. It took a while to find the root cause as the stack trace lacked a lot of detail. Ultimately it was a &lt;strong&gt;SwiftUI &lt;code&gt;Color&lt;/code&gt;&lt;/strong&gt; in a &lt;strong&gt;UIKit&lt;/strong&gt; API that expects a &lt;code&gt;UIColor&lt;/code&gt; (or raw &lt;code&gt;CGColor&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;In this case I passed a SwiftUI &lt;code&gt;Color&lt;/code&gt; via the &lt;code&gt;.foregroundColor&lt;/code&gt; attribute of an &lt;code&gt;NSAttributedString&lt;/code&gt; that UIKit then rendered.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using Context Menu with Previews in SwiftUI</title>
      <link>https://www.mikegopsill.com/posts/swiftui-context-menu-previews/</link>
      <pubDate>Sun, 11 May 2025 08:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swiftui-context-menu-previews/</guid>
      <description>&lt;p&gt;SwiftUI’s &lt;code&gt;contextMenu&lt;/code&gt; modifier is a simple API that does a lot for us.&lt;/p&gt;
&lt;p&gt;I wrote about &lt;strong&gt;building context menus in both &lt;a href=&#34;https://www.mikegopsill.com/posts/uikit-context-menus/&#34;&gt;UIKit&lt;/a&gt; and &lt;a href=&#34;https://www.mikegopsill.com/posts/swiftui-context-menus/&#34;&gt;SwiftUI&lt;/a&gt;&lt;/strong&gt; recently. I did not go into detail about support for the &lt;strong&gt;custom previews&lt;/strong&gt; that landed in iOS 16, iPadOS 16 and macOS 13. Let us fill that gap.&lt;/p&gt;
&lt;h2 id=&#34;recap-context-menus-in-swiftui&#34;&gt;Recap: Context menus in SwiftUI&lt;/h2&gt;
&lt;p&gt;A context menu is equivalent of a right-click on touch devices. Using long‑press (or Control‑click on the Mac) on a view reveals a menu of options exactly where the user needs it. In pure SwiftUI we use &lt;code&gt;.contextMenu&lt;/code&gt; to create these menus:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use Context Menus in UIKit</title>
      <link>https://www.mikegopsill.com/posts/uikit-context-menus/</link>
      <pubDate>Fri, 09 May 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/uikit-context-menus/</guid>
      <description>&lt;p&gt;In this post we&amp;rsquo;re going to add context menus to a UIKit &lt;code&gt;UITableView&lt;/code&gt;. The end goal is to have something that looks like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&#34;Context-menu demo UIKit&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/uikit-context-menus/context-menu-demo-uikit.gif#center&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;why-use-context-menus&#34;&gt;Why Use Context Menus?&lt;/h2&gt;
&lt;p&gt;Context menus are great for keeping things tidy while still offering useful features. They:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Keep your UI minimal&lt;/li&gt;
&lt;li&gt;Only show options when needed&lt;/li&gt;
&lt;li&gt;Feel natural with the iOS long-press gesture&lt;/li&gt;
&lt;li&gt;Save you adding extra buttons all over the UI – the menu keeps them tucked out of sight until needed.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;what-were-making&#34;&gt;What We’re Making&lt;/h2&gt;
&lt;p&gt;We’ll show a short list of fruit. When we long-press any item we will show a context menu with three options:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use Context Menus in SwiftUI</title>
      <link>https://www.mikegopsill.com/posts/swiftui-context-menus/</link>
      <pubDate>Thu, 08 May 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swiftui-context-menus/</guid>
      <description>&lt;p&gt;The aim for this post to build a very simple &lt;code&gt;List&lt;/code&gt; view. When you long-press a row you will see a classic iOS context menu. It will look a little like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&#34;Context-menu demo&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/swiftui-context-menus/context-menu-demo.gif#center&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;why-context-menus&#34;&gt;Why Context Menus?&lt;/h2&gt;
&lt;p&gt;Context menus give users an easy way to discover secondary actions &lt;em&gt;right where they’re looking&lt;/em&gt;. They:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Keep the primary UI clean.&lt;/li&gt;
&lt;li&gt;Surface actions only when they’re relevant.&lt;/li&gt;
&lt;li&gt;Feel familiar thanks to the long-press gesture we already use across iOS.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;what-well-build&#34;&gt;What We’ll Build&lt;/h2&gt;
&lt;p&gt;We’ll create a simple list of fruit. A long-press on any row reveals three actions:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
