<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Fumiya Yamanaka</title>
    <description>The latest articles on Forem by Fumiya Yamanaka (@mtfum).</description>
    <link>https://forem.com/mtfum</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F105309%2F89a3b702-4f83-4e93-86e1-598d4f37e583.png</url>
      <title>Forem: Fumiya Yamanaka</title>
      <link>https://forem.com/mtfum</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mtfum"/>
    <language>en</language>
    <item>
      <title>[SwiftUI] How I Built OSS News App</title>
      <dc:creator>Fumiya Yamanaka</dc:creator>
      <pubDate>Sun, 13 Feb 2022 21:35:58 +0000</pubDate>
      <link>https://forem.com/mtfum/build-a-oss-news-app-with-swiftui-2lpi</link>
      <guid>https://forem.com/mtfum/build-a-oss-news-app-with-swiftui-2lpi</guid>
      <description>&lt;p&gt;This post is originally &lt;a href="https://zenn.dev/mtfum/articles/7540aef4ffb3a27bf37c" rel="noopener noreferrer"&gt;published in Japanese&lt;/a&gt; a half years ago. I want someone to know how create an iOS app with modern technology and how I struggled with that. Please enjoy!!&lt;/p&gt;




&lt;p&gt;I built an OSS news app for iOS with SwiftUI. &lt;br&gt;
Please give me stars on GitHub!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mtfum" rel="noopener noreferrer"&gt;
        mtfum
      &lt;/a&gt; / &lt;a href="https://github.com/mtfum/NewsUI" rel="noopener noreferrer"&gt;
        NewsUI
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Simple news iOS app with SwiftUI 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;NewsUI&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;Simple news iOS app with SwiftUI 🗞️ which uses NewsAPI to fetch top news headlines&lt;/p&gt;
&lt;p&gt;The codebase uses following modern keys:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SwiftUI&lt;/li&gt;
&lt;li&gt;Async/Await&lt;/li&gt;
&lt;li&gt;Swift Package Manager&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Get Headlines&lt;/li&gt;
&lt;li&gt;Search News&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Requirements&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Xcode13+&lt;/li&gt;
&lt;li&gt;iOS 15+&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Getting started&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git clone https://github.com/mtfum/NewsUI&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;cd NewsUI&lt;/li&gt;
&lt;li&gt;insert &lt;code&gt;YOUR_NEWS_API_KEY&lt;/code&gt; in &lt;code&gt;NewsClient.swift&lt;/code&gt;, you can get from &lt;a href="https://newsapi.org/" rel="nofollow noopener noreferrer"&gt;https://newsapi.org/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Build SwiftUIApp&lt;/li&gt;
&lt;li&gt;Enjoy! 🎉&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Libraries&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mtfum/NewsAPI" rel="noopener noreferrer"&gt;NewsAPI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/apple/swift-collections" rel="noopener noreferrer"&gt;SwiftCollections&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Architecture&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/mtfum/NewsUI./images/ArchitectureImage.jpg"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fmtfum%2FNewsUI.%2Fimages%2FArchitectureImage.jpg" alt="Architecture"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mtfum/NewsUI" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;



&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mtfum" rel="noopener noreferrer"&gt;
        mtfum
      &lt;/a&gt; / &lt;a href="https://github.com/mtfum/NewsAPI" rel="noopener noreferrer"&gt;
        NewsAPI
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      An unofficial supported Swift client library for accessing News API.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;NewsAPI&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;An API framework for &lt;a href="https://newsapi.org/" rel="nofollow noopener noreferrer"&gt;newsapi.org&lt;/a&gt; with Swift.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Requirement&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Swift5.5+&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Installation&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Swift Package Manager&lt;/h3&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-swift notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;package&lt;span class="pl-kos"&gt;(&lt;/span&gt;url&lt;span class="pl-kos"&gt;:&lt;/span&gt; &lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-s"&gt;https://github.com/mtfum/NewsAPI.git&lt;/span&gt;&lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; from&lt;span class="pl-kos"&gt;:&lt;/span&gt; &lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-s"&gt;0.1.0&lt;/span&gt;&lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Usage&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Setup&lt;/h3&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-swift notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;import NewsAPI

&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-s1"&gt;client&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;NewsAPI&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;apiKey&lt;span class="pl-kos"&gt;:&lt;/span&gt; &lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_API_KEY&lt;/span&gt;&lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Get Sources&lt;/h3&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-swift notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-s1"&gt;articles&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;&lt;span class="pl-k"&gt;try&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;await&lt;/span&gt; client&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;getSources&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;
    sources&lt;span class="pl-kos"&gt;:&lt;/span&gt; &lt;span class="pl-kos"&gt;[&lt;/span&gt;String&lt;span class="pl-kos"&gt;]&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-kos"&gt;[&lt;/span&gt;&lt;span class="pl-kos"&gt;]&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c"&gt;// abc-news, bbc-news, etc...&lt;/span&gt;
    query&lt;span class="pl-kos"&gt;:&lt;/span&gt; String&lt;span class="pl-c1"&gt;&lt;span class="pl-c1"&gt;?&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;nil&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    category&lt;span class="pl-kos"&gt;:&lt;/span&gt; NewsSourceCategory&lt;span class="pl-c1"&gt;&lt;span class="pl-c1"&gt;?&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;nil&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    language&lt;span class="pl-kos"&gt;:&lt;/span&gt; Language &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;Language&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;en
&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Search&lt;/h3&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-swift notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-s1"&gt;articles&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;&lt;span class="pl-k"&gt;try&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;await&lt;/span&gt; client&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;search&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;
  query&lt;span class="pl-kos"&gt;:&lt;/span&gt; &lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-s"&gt;"&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  sources&lt;span class="pl-kos"&gt;:&lt;/span&gt; &lt;span class="pl-kos"&gt;[&lt;/span&gt;String&lt;span class="pl-kos"&gt;]&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-kos"&gt;[&lt;/span&gt;&lt;span class="pl-kos"&gt;]&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  sortBy&lt;span class="pl-kos"&gt;:&lt;/span&gt; SortBy&lt;span class="pl-c1"&gt;&lt;span class="pl-c1"&gt;?&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;nil&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c"&gt;// relevancy, popularity, publishedAt&lt;/span&gt;
  language&lt;span class="pl-kos"&gt;:&lt;/span&gt; Language&lt;span class="pl-c1"&gt;&lt;span class="pl-c1"&gt;?&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;nil&lt;/span&gt;
&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Top-Headlines&lt;/h3&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-swift notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-s1"&gt;articles&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;&lt;span class="pl-k"&gt;try&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;await&lt;/span&gt; client&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;getTopHeadlines&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;
  category&lt;span class="pl-kos"&gt;:&lt;/span&gt; NewsSourceCategory&lt;span class="pl-c1"&gt;&lt;span class="pl-c1"&gt;?&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-smi"&gt;nil&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  language&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mtfum/NewsAPI" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Why I built this
&lt;/h2&gt;

&lt;p&gt;Apple had released a lot of new API in WWDC 2021. Everything is very exciting and motivated me to create a new app though, I just wanted to experiment the new feature like &lt;a href="https://developer.apple.com/documentation/swiftui/emptyview/searchable(text:placement:)" rel="noopener noreferrer"&gt;Searchable&lt;/a&gt; and &lt;a href="https://developer.apple.com/documentation/swiftui/image/refreshable(action:)" rel="noopener noreferrer"&gt;Refreshable&lt;/a&gt; or new feature of Swift language like Concurrency.&lt;/p&gt;

&lt;p&gt;Therefore, the app itself requires Xcode 13 or higher and iOS 15 or higher.&lt;/p&gt;

&lt;h2&gt;
  
  
  About App
&lt;/h2&gt;

&lt;p&gt;This app uses the &lt;a href="https://newsapi.org/" rel="noopener noreferrer"&gt;newsapi.org&lt;/a&gt; API to search for the world's top news and specific words.&lt;br&gt;
It consists of three tabs and implements only the minimum necessary functions.&lt;br&gt;
I'm personally satisfied with it because it accomplished the purpose of trying out the new features I mentioned above.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Headline&lt;/th&gt;
&lt;th&gt;Search&lt;/th&gt;
&lt;th&gt;Publishers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fturrma68r7pq2wgc1wej.png" alt="Screenshot for Headline"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyc0bsl0d7r7fbmcwr7b.png" alt="Screenshot for Search"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2draxx1qx1t8lgg0egt.png" alt="Screenshot for Publishers"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  NewsAPI: Concurrency
&lt;/h2&gt;

&lt;p&gt;With the creation of the app, I wrapped the API of newsapi.org and released it as an iOS library.&lt;br&gt;
I could have left it as an internal implementation, but I cut it out as a library for the following reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There was no Swift library for newsapi that supported asynchronous processing.&lt;/li&gt;
&lt;li&gt;I want people who want to make iOS apps to use it.&lt;/li&gt;
&lt;li&gt;I wanted to do it as a part of OSS activity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From here, I will lightly introduce the API that uses &lt;code&gt;async/await&lt;/code&gt; syntax, the most significant language feature added in Swift 5.5.&lt;br&gt;
The following is a sample code that uses the NewsAPI to get the headline news.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;getHeadlines&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;NewsArticle&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;articles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kt"&gt;NewsAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"YOUR_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTopHeadlines&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;articles&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you read the above code, you will see that instead of using traditional closures, the keyword &lt;code&gt;async&lt;/code&gt; is added to the method and the keyword &lt;code&gt;await&lt;/code&gt; is used inside.&lt;br&gt;
This method, &lt;code&gt;getHeadlines&lt;/code&gt;, is defined as an asynchronous function, so it needs the &lt;code&gt;await&lt;/code&gt; keyword right before it.&lt;br&gt;
Since &lt;code&gt;await&lt;/code&gt; suspends the process immediately after it is written, it is more intuitive to write.&lt;br&gt;
Not only does it improve readability by reducing the number of lines of code and the depth of nesting, but it also expands the scope of expression by allowing multiple asynchronous processes to be handled simultaneously.&lt;/p&gt;
&lt;h2&gt;
  
  
  NewsUI: App Architecture
&lt;/h2&gt;

&lt;p&gt;Here is an explanation of the application itself.&lt;br&gt;
The following image shows an easy-to-understand diagram of the app structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4pmzymope0de4co6a2ra.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4pmzymope0de4co6a2ra.jpeg" alt="NewsUI App Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned in the above section, NewsAPI (red part) has been cut out as an external library.&lt;br&gt;
Only the internal &lt;code&gt;NewsClient&lt;/code&gt; depends on the &lt;code&gt;NewsAPI&lt;/code&gt;, and each feature depends on it.&lt;br&gt;
All the features in the yellow part of the image are managed as Packages, and the &lt;code&gt;Package.json&lt;/code&gt; file is structured as follows.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="c1"&gt;// https://github.com/mtfum/NewsUI/blob/main/Package.swift&lt;/span&gt;

&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;PackageDescription&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;package&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Package&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"NewsUI"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nv"&gt;platforms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iOS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"15.0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="nv"&gt;products&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AppFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"AppFeature"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"SearchFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"SearchFeature"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"HeadlinesFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"HeadlinesFeature"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"SourcesFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"SourcesFeature"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;package&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"https://github.com/mtfum/NewsAPI.git"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"0.1.0"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;package&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"https://github.com/apple/swift-collections.git"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"0.0.1"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="nv"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;target&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AppComponent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"NewsAPI"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;target&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AppFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"SearchFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"HeadlinesFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"SourcesFeature"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;target&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"NewsClient"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"NewsAPI"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;target&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"SearchFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"AppComponent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"NewsClient"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"OrderedCollections"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;package&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"swift-collections"&lt;/span&gt;&lt;span class="p"&gt;)]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;target&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"HeadlinesFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"AppComponent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"NewsClient"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;target&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"SourcesFeature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"AppComponent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"NewsClient"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The app is divided into multiple modules, and each module is divided into different functions (in this case, tabs) so that they cannot be cross-referenced.&lt;br&gt;
Multi-module system has some merits such as clear dependencies and optimized compilation, but for a small app like this one, you won't get much benefit from it.&lt;/p&gt;



&lt;p&gt;Though it is an unnecessary addition, we call it Hyper-modularization, and &lt;a href="https://github.com/pointfreeco/isowords" rel="noopener noreferrer"&gt;isowords&lt;/a&gt; is being developed with 86 modules.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/pointfreeco" rel="noopener noreferrer"&gt;
        pointfreeco
      &lt;/a&gt; / &lt;a href="https://github.com/pointfreeco/isowords" rel="noopener noreferrer"&gt;
        isowords
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Open source game built in SwiftUI and the Composable Architecture.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;isowords&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/pointfreeco/isowords/actions/workflows/ci.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/pointfreeco/isowords/actions/workflows/ci.yml/badge.svg" alt="CI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This repo contains the full source code for &lt;a href="https://www.isowords.xyz" rel="nofollow noopener noreferrer"&gt;isowords&lt;/a&gt;, an iOS word search game played on a vanishing cube. Connect touching letters to form words, the longer the better, and the third time a letter is used its cube is removed, revealing more letters inside!&lt;/p&gt;

&lt;p&gt;Available on the &lt;a href="https://www.isowords.xyz/app-store" rel="nofollow noopener noreferrer"&gt;App Store&lt;/a&gt; now!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.isowords.xyz/app-store" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/703ba8be69bff475ccaa81e6fba5b9bc998bd416be7585bc99e9395de46222b2/68747470733a2f2f64627371686f333363677034792e636c6f756466726f6e742e6e65742f6769746875622f6170702d73746f72652d62616467652e706e67" alt="Download isowords on the App Store"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.isowords.xyz/app-store" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/ac33a29fd9c58d4f30811c1a18553f5197406cb3c1cefaa0a6f9479e2387d173/68747470733a2f2f64627371686f333363677034792e636c6f756466726f6e742e6e65742f6769746875622f69736f776f7264732d73637265656e73686f74732e6a7067" alt="isowords screenshots"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/pointfreeco/isowords#about" rel="noopener noreferrer"&gt;About&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pointfreeco/isowords#getting-started" rel="noopener noreferrer"&gt;Getting Started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pointfreeco/isowords#learn-more" rel="noopener noreferrer"&gt;Learn More&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pointfreeco/isowords#related-projects" rel="noopener noreferrer"&gt;Related Projects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pointfreeco/isowords#license" rel="noopener noreferrer"&gt;License&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;About&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.isowords.xyz" rel="nofollow noopener noreferrer"&gt;isowords&lt;/a&gt; is a large, complex application built entirely in Swift. The iOS client's logic is built in the &lt;a href="https://github.com/pointfreeco/swift-composable-architecture" rel="noopener noreferrer"&gt;Composable Architecture&lt;/a&gt; and the UI is built mostly in SwiftUI with a little bit in SceneKit. The server is also built in Swift using our experimental web server libraries.&lt;/p&gt;

&lt;p&gt;We published a &lt;a href="https://www.pointfree.co/collections/tours/isowords" rel="nofollow noopener noreferrer"&gt;4-part series of videos&lt;/a&gt; covering these topics and more on &lt;a href="https://www.pointfree.co" rel="nofollow noopener noreferrer"&gt;Point-Free&lt;/a&gt;, a video series exploring functional programming and the Swift language, hosted by &lt;a href="https://twitter.com/mbrandonw" rel="nofollow noopener noreferrer"&gt;Brandon Williams&lt;/a&gt; and &lt;a href="https://twitter.com/stephencelis" rel="nofollow noopener noreferrer"&gt;Stephen Celis&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pointfree.co/collections/tours/isowords" rel="nofollow noopener noreferrer"&gt;&lt;br&gt;
  &lt;img alt="video poster image" src="https://camo.githubusercontent.com/312b57f75be450357093426c657c972e9a0cc0a343d194c54b6db4a2eeac4163/68747470733a2f2f6433726363646e33337274387a652e636c6f756466726f6e742e6e65742f657069736f6465732f303136392e6a706567" width="600"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Some things you might find interesting:&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;The Composable&lt;/h3&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/pointfreeco/isowords" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;






&lt;p&gt;In addition, each feature was integrated into the AppFeature, and the app itself could be simply configured to refer to the AppFeature.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;SwiftUI&lt;/span&gt;
&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;AppFeature&lt;/span&gt;

&lt;span class="kd"&gt;@main&lt;/span&gt;
&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;NewsUIApp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;some&lt;/span&gt; &lt;span class="kt"&gt;Scene&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;WindowGroup&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kt"&gt;AppFeatureView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;This is a brief introduction to &lt;a href="https://github.com/mtfum/NewsUI" rel="noopener noreferrer"&gt;NewsUI&lt;/a&gt; and &lt;a href="https://github.com/mtfum/NewsAPI" rel="noopener noreferrer"&gt;NewsAPI&lt;/a&gt;, which I have been working on.&lt;br&gt;
I'm happy to publish it now that I have a breakthrough for now.&lt;br&gt;
Please star if you find it helpful!&lt;br&gt;
Thank you for reading.&lt;/p&gt;

</description>
      <category>swift</category>
      <category>swiftui</category>
      <category>concurrency</category>
      <category>ios15</category>
    </item>
    <item>
      <title>[Swift] What I learned about Memoization </title>
      <dc:creator>Fumiya Yamanaka</dc:creator>
      <pubDate>Sun, 13 Feb 2022 01:54:21 +0000</pubDate>
      <link>https://forem.com/mtfum/swift-what-i-learned-about-memoization-44ac</link>
      <guid>https://forem.com/mtfum/swift-what-i-learned-about-memoization-44ac</guid>
      <description>&lt;p&gt;This post is originally created on May and published on my &lt;a href="https://mtfum.dev/"&gt;personal blog&lt;/a&gt;.&lt;br&gt;
However,  I changed my mind. I noticed that publishing it on the platform is better than on mine because someone can reach out whenever.&lt;/p&gt;



&lt;p&gt;The terminology of 'memoization' is very impressive and motivated me to learn new things. Today, I want to share a good effect and show an example. I learned by Javascript in the class so I will try use Swift.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Memoization
&lt;/h2&gt;

&lt;p&gt;According to Wikipedia, memoization is &lt;strong&gt;&lt;em&gt;an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. Memoization has also been used in other contexts (and for purposes other than speed gains), such as in simple mutually recursive descent parsing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, we use the recursive function to simplify the complicated algorithm. &lt;/p&gt;

&lt;p&gt;However, it may become the reason to slow down. Then, you need to change the algorithm or use memoization.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;For example, there is one of the famous algorithms 'fibonacci sequence'. You'll see the simple code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the most simple solution. If given number is more than 2, calculate the sum of the last two number. &lt;/p&gt;

&lt;p&gt;If you are interested in more details about &lt;code&gt;fibonacci&lt;/code&gt;, please search yourself.&lt;/p&gt;

&lt;p&gt;On the other hand, let's code with memoization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;]()&lt;/span&gt;
&lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;cachedFibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;v&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;newValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;cachedFibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;cachedFibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newValue&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;newValue&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example code is quiet manual but very useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing methods
&lt;/h2&gt;

&lt;p&gt;we can measure time since Jan, 1, 2001 to use &lt;code&gt;CFAbsoluteTimeGetCurrent&lt;/code&gt; in Xcode playground.&lt;/p&gt;

&lt;p&gt;At this time, it is enable to get the difference  to call this function with calling fibonacci function before and after, and calculate the gap of them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;start1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;CFAbsoluteTimeGetCurrent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;diff1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;CFAbsoluteTimeGetCurrent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start1&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// 0.05279099941253662&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;start2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;CFAbsoluteTimeGetCurrent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;cachedFibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;diff2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;CFAbsoluteTimeGetCurrent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start2&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// 0.00033092498779296875&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Obviously, time with memoization is 100 times faster than the one without memoization.&lt;/p&gt;

&lt;p&gt;This is the reason why we should implement the algorithm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Today, I introduced about memoization with using fibonacci sequence.&lt;/p&gt;

&lt;p&gt;Actually when measured the time gap, you can see the necessarily.&lt;/p&gt;

&lt;p&gt;If you faced to the issue like slow functions, I hope you recall this article. &lt;/p&gt;

&lt;p&gt;Thank you! Enjoy your coding.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Memoization"&gt;Memoization - Wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Fibonacci_number"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hackingwithswift.com/plus/high-performance-apps/using-memoization-to-speed-up-slow-functions"&gt;Using memoization to speed up slow functions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hackingwithswift.com/example-code/system/measuring-execution-speed-using-cfabsolutetimegetcurrent"&gt;Measuring execution speed using CFAbsoluteTimeGetCurrent()&lt;/a&gt;&lt;/p&gt;

</description>
      <category>swift</category>
      <category>engineering</category>
    </item>
    <item>
      <title>August Review 2021</title>
      <dc:creator>Fumiya Yamanaka</dc:creator>
      <pubDate>Fri, 03 Sep 2021 02:08:31 +0000</pubDate>
      <link>https://forem.com/mtfum/august-review-2021-52m</link>
      <guid>https://forem.com/mtfum/august-review-2021-52m</guid>
      <description>&lt;p&gt;August was a very productive month for me.&lt;br&gt;
Recently, I'm struggling with some technological stuff. The reason for this is because I don't know what I should learn, what I need for get a job, or what I want to keep developing.&lt;br&gt;
Anyway, I want to share my knowledge and lesson in August.&lt;br&gt;
I hope you'll enjoy my first entry on dev.to!&lt;/p&gt;

&lt;h1&gt;
  
  
  Kaggle
&lt;/h1&gt;

&lt;p&gt;At first, I've tried to get started &lt;a href="http://kaggle.com/"&gt;Kaggle&lt;/a&gt;. It was my first touch of machine learning.&lt;/p&gt;

&lt;p&gt;Kaggle took the challenge called &lt;a href="https://www.kaggle.com/thirty-days-of-ml"&gt;30 Days of ML&lt;/a&gt; in August. When I saw it firstly, I was reluctant because I thought I can't do such ML things. However, I have an app idea using machine learning and a lot of free time. I felt it's the best time to learn ML. &lt;/p&gt;

&lt;p&gt;The beginning started from Python grammar to actual technic like Model validation, a better way test and so on. There are a lot of terminology I have to memorize, but I can't yet. &lt;/p&gt;

&lt;p&gt;I realized that this might not for me as a result of my through experience again. I don't like mastering machine learning, but want to use it to build an app. I knew it from the beginning but I could truly understand from the bottom of my heart and learn how to build machine learning model.&lt;/p&gt;

&lt;h1&gt;
  
  
  Pizza Classifier
&lt;/h1&gt;

&lt;p&gt;Secondly, I tried classification of the images. As I wrote the above section, I thought I don't need to build ML model by myself. Apple published a desktop app for machine learning a few years ago, It's called &lt;a href="https://developer.apple.com/machine-learning/create-ml/"&gt;CreateML&lt;/a&gt;. Using CreateML gives you the opportunity to train your own ML model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/mtfum/PizzaClassifier"&gt;Pizza Classifier&lt;/a&gt; is a sample implementation of pizza classification app with CreatML and SwiftUI. At this time, I collected 7 types pizza images and then train and test it. Accuracy is not enough to use this app on a daily basis though, I'm satisfied with what I've learned about the way to create an ML model.&lt;/p&gt;

&lt;p&gt;What I learned at Kaggle helped me to build ML model because I knew the reason why and how I should divide into training models and test models, at this time it's images, and how to analyze the predictions and outputs. I felt kind of connecting the dots.&lt;/p&gt;

&lt;p&gt;GitHub Repository: &lt;a href="https://github.com/mtfum/PizzaClassifier"&gt;https://github.com/mtfum/PizzaClassifier&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Object Tracking &amp;amp; AR
&lt;/h1&gt;

&lt;p&gt;Third project was AR app with &lt;a href="https://developer.apple.com/documentation/ARKit"&gt;ARKit&lt;/a&gt; and &lt;a href="https://developer.apple.com/documentation/vision"&gt;Vision&lt;/a&gt;.&lt;br&gt;
Firstly, I wanted to create an app to help people who want to learn new language with showing translated words in AR world. &lt;/p&gt;

&lt;p&gt;This basic idea depends on &lt;a href="https://github.com/hanleyweng/CoreML-in-ARKit"&gt;this GitHub Repo(CoreML-in-ARKit)&lt;/a&gt;. It works yet, so I didn't need to build from scratch. What a luck!&lt;/p&gt;

&lt;p&gt;The keys of this idea are an accuracy and quantity of models though, I tried to use &lt;a href="https://developer.apple.com/machine-learning/models/"&gt;multiplex models&lt;/a&gt;. However, There is no models to work perfectly.&lt;/p&gt;

&lt;p&gt;Other than that, I know there're possibilities to build up with &lt;a href="https://developers.google.com/ml-kit/vision/image-labeling"&gt;MLKit&lt;/a&gt; or some frameworks, honestly, I was getting bored so that deprioritized. &lt;br&gt;
There seems to be a long path to reach out to my ideal app.&lt;/p&gt;

&lt;h1&gt;
  
  
  Twitter Spaces Search
&lt;/h1&gt;

&lt;p&gt;This is the last project in August.&lt;br&gt;
I built the basic app with taking a distance from ML.&lt;br&gt;
I realized nobody tried to use &lt;a href="https://blog.twitter.com/developer/en_us/topics/tools/2021/shape-the-future-of-twitter-spaces"&gt;Twitter API v2 for searching Twitter Spaces&lt;/a&gt;. Thus, I created the app which allows us to look for Spaces with a specific word. &lt;/p&gt;

&lt;p&gt;It contains some bugs so that I wasn't enabled to finalize it in August. But, actually, I published my repository and keep to build it.&lt;/p&gt;

&lt;p&gt;GitHub Repository: &lt;a href="https://github.com/mtfum/TwitterSpacesSearch/"&gt;https://github.com/mtfum/TwitterSpacesSearch/&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Wrapped up
&lt;/h1&gt;

&lt;p&gt;My writing skill in English is very slow like snails so the release of this article delayed by a few days. As above ideas I wrote, it's hard to make ideas into a practical and useful app. I have a lot of ideas but I feel I don't have enough skill to build up. Moreover, it would be meaningless unless nobody knows my app and progress. It's the reason I'm writing this article. From now, I want to share my thought and idea at least once a month. So then follow me dev.to and Twitter if you're interested in.&lt;/p&gt;

&lt;p&gt;Thank you for you reading! See ya!&lt;/p&gt;

</description>
      <category>swift</category>
      <category>kaggle</category>
      <category>arkit</category>
      <category>swiftui</category>
    </item>
  </channel>
</rss>
