<?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 Pattaravadee Luamsomboon on Medium]]></title>
        <description><![CDATA[Stories by Pattaravadee Luamsomboon on Medium]]></description>
        <link>https://medium.com/@forzfilm?source=rss-39680d8dd79b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bPSYIbuBrkrwfwEYT995pA@2x.jpeg</url>
            <title>Stories by Pattaravadee Luamsomboon on Medium</title>
            <link>https://medium.com/@forzfilm?source=rss-39680d8dd79b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 04:32:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@forzfilm/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[How to run Unit Tests and measure coverage only for business logic files]]></title>
            <link>https://forzfilm.medium.com/how-to-run-unit-tests-and-measure-coverage-only-for-business-logic-files-a1b870b32717?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1b870b32717</guid>
            <category><![CDATA[unittest]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 14:20:52 GMT</pubDate>
            <atom:updated>2025-12-18T09:21:52.330Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InhYha8yhs_sHZoy2F9nBA.png" /></figure><p>Hello world! 🙌🏼🌎 It’s been quite a long time since I last wrote a blog. <br>Today I’d like to share a technique for getting accurate code coverage from your iOS project. You can use this approach for your local development or integrate it into your CI/CD pipeline🤖.</p><h4>🚩 The Problem: Noisy and Misleading Code Coverage</h4><p>In any iOS architecture — MVVM, VIPER, MVP, or Clean Swift — your target contains many different kinds of files: models, view models, presenters, views, DTOs, routers, workers, and so on.</p><p>But when we talk about <strong>meaningful</strong> code coverage, what we really care about is the <strong>business logic:</strong></p><ul><li>ViewModel</li><li>Presenter</li><li>Interactor</li><li>etc.</li></ul><p>The problem is…<br>When you run unit tests, <strong>Xcode calculates code coverage for every file in your target</strong>.<br>So instead of clean and focused coverage, you get a messy percentage that doesn’t tell you anything useful.</p><h4>📂 Example</h4><p>Here’s the structure of my sample project.<br>I use modularization by splitting each feature into its own .xcodeproj.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*Gi0eG7acxjnVeZjbmYviPA.png" /></figure><p>When I want to test the <em>ToDoList</em> feature, I select the custom scheme ToDoList_Example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-P0NQzXbf8z5ZXgS7RPO8g.png" /></figure><p><strong>And the result looks like this:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c47SZWoc49G0m_SkNCtEEA.png" /></figure><p>Even though my ViewModel has <strong>100% coverage</strong>, Xcode still reports <strong>16.9%</strong>, because it includes all files in the module.</p><blockquote>And that’s when I thought:<br><strong>There has to be a way to get code coverage only for the logic that actually matters.</strong></blockquote><h4>✅ Two Possible Solutions</h4><p>I found two ways to solve this issue.</p><p><strong>1️⃣ Restructure your project</strong></p><p>You can extract all ViewModels into a new project like ViewModel.xcodeproj, then create a scheme specifically for that module.</p><p>But…</p><ul><li>It requires restructuring an existing project</li><li>It’s not convenient for large codebases</li><li>It adds maintenance overhead</li></ul><p>This is <em>not</em> the approach I chose.</p><p>⭐️ 2️⃣ <strong>Keep your existing structure — use </strong><strong>xcov + filtering</strong></p><p>This method doesn’t require changing your project at all.<br>You only need to do <strong>three</strong> things:</p><p>2.1 Install xcov</p><pre>sudo gem install xcov</pre><p>2.2 Create a shell script to run tests and generate the xcov report</p><p>Example: test_todo_list.sh</p><pre># Check existing foler and remove before test<br>BUILD_PATH=&quot;build&quot;<br><br>if [ -d &quot;$BUILD_PATH&quot; ]; then<br>  echo &quot;BUILD_PATH exists. Removing $BUILD_PATH&quot;<br>  rm -rf &quot;$BUILD_PATH&quot;<br>else<br>  echo &quot;BUILD_PATH does not exist. Nothing to remove.&quot;<br>fi<br><br>XCOV_PATH=&quot;xcov_report&quot;<br><br>if [ -d &quot;$XCOV_PATH&quot; ]; then<br>  echo &quot;XCOV_PATH exists. Removing $XCOV_PATH&quot;<br>  rm -rf &quot;$XCOV_PATH&quot;<br>else<br>  echo &quot;XCOV_PATH does not exist. Nothing to remove.&quot;<br>fi<br>xcodebuild test \<br>  -workspace Example1.xcworkspace \        # change to your workspace<br>  -scheme &quot;ToDoList_Example&quot; \             # change to your scheme<br>  -configuration Debug \<br>  -destination &#39;platform=iOS Simulator,name=iPhone 16 Pro,OS=18.4&#39; \  # customize destination<br>  -enableCodeCoverage YES \<br>  -resultBundlePath build/Test.xcresult    # where the xcresult will be stored<br><br>xcov \<br>  --workspace Example1.xcworkspace \<br>  --scheme ToDoList_Example \<br>  --include_targets &quot;ToDoList.framework&quot; \<br>  --ignore_file_path .xcovignore           # from step 2.3</pre><p>2.3 Create a .xcovignore file to exclude unwanted files<br>Here’s an example (customize as needed):</p><pre># Ignore everything except Presenter &amp; Interactor (For VIPER)<br>- ^(?!.*(Presenter|Interactor)).*\.swift<br># Ignore everything except ViewModel (For MVVM)<br>- ^(?!.*ViewModel).*\.swift</pre><p>Run it with:</p><pre>sh test_todo_list.sh</pre><h4>🎉 Result</h4><p>Once you run the script, xcov generates code coverage <strong>only for business logic files</strong>, and ignores everything unrelated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*IUbPVd6wugztJLpqB96yWQ.png" /></figure><p>Now you finally get clean, accurate, meaningful coverage.. 🎉🎉🎉</p><h3>📦 Example Repository</h3><p>To make this easier to follow, I’ve created a sample repository that demonstrates the full setup — including modular structure, test schemes, the xcov script, and .xcovignore configuration.</p><p>You can explore the project, run the tests, and experiment with the ignore rules to better understand how this approach works in practice.</p><p>👉 <strong>Example repository:</strong><br><a href="https://github.com/forzfilm/unit-test-script">Repo</a></p><p>Feel free to clone it and adapt the setup to your own project.</p><h4>🔚 Final Thoughts</h4><p>Accurate code coverage becomes especially important as your project grows or becomes modular.<br>By combining xcodebuild with xcov and a proper ignore list, you can focus coverage results on the files that truly matter — without restructuring your project or maintaining a separate module.</p><p>This approach helps you measure the real quality of your business logic and keeps your testing workflow simple, clean, and scalable.</p><p>Thank you for taking the time to read my blog. I hope this technique helps make your testing process clearer and more effective. 🙏🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1b870b32717" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[สิ่งใดเล่าคือ xcframework ในยุทธภพของ iOS dev]]></title>
            <link>https://medium.com/finnomena/%E0%B8%AA%E0%B8%B4%E0%B9%88%E0%B8%87%E0%B9%83%E0%B8%94%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%B2%E0%B8%84%E0%B8%B7%E0%B8%AD-xcframework-%E0%B9%83%E0%B8%99%E0%B8%A2%E0%B8%B8%E0%B8%97%E0%B8%98%E0%B8%A0%E0%B8%9E%E0%B8%82%E0%B8%AD%E0%B8%87-ios-dev-2c7110c4af65?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c7110c4af65</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[xcframework]]></category>
            <category><![CDATA[modular]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 05:01:29 GMT</pubDate>
            <atom:updated>2022-10-07T09:47:55.561Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ik5SpxTUe9XQJUG0kjo-_A.png" /></figure><p>สวัสดีชาวโลก 🌍🌍🌍 blog แรกของปี 2022 (จะจบปีอยู่ละ) จะเป็น blog เดียวของปีด้วยมั้ยเนี่ย 😂😂😂 โดยไม่รีรอเย๊อะ…สำหรับ blog นี้จะพาทุกคนไปรู้จักกับ xcframework พอดีช่วงเวลาที่ผ่านมาได้มีโอกาสลงไปคลุกคลีกับการทำ modular architecture iOS ซึ่งการทำ modular เนี่ย ก็เพื่อให้ project ของเราที่เริ่มใหญ่ขึ้นเรื่อยๆ ถูกแยกออกมาเป็นส่วนๆ จะได้ดูแลโค้ดในแต่ละส่วนได้ง่ายๆ แล้วแต่ละส่วนก็อาจจะถูกนำไป reuse ที่ project อื่นๆ ได้ด้วย เช่น เราอาจจะแยกเป็น core ui, core networking, login feature เป็นต้น พอต้องแยกของออกมาแบบนี้เลยถูกพ่วงมาด้วยการทำxcframework นั่นเอง เดี๋ยวไปอ่านกันว่าจะมีเนื้อหาอะไรให้ทุกคนได้อ่านกันบ้าง</p><p><strong>สิ่งที่จะเขียนถึงใน blog นี้</strong></p><ul><li>xcframework คือสิ่งใดในยุทธภพเรา</li><li>xcframework เกิดมาเพื่ออออออ</li><li>วิทยายุทธการสร้าง xcframework</li></ul><p>มาเริ่มกันที่หัวข้อแรกกันเลย <strong>xcframework คือสิ่งใดในยุทธภพเรา</strong></p><p>xcframework ก็คือ framework ยังไงล๊าาาา ไม่มุก ไม่ตลกนะ มันคือ framework จริงๆ เป็น binary framework format ใหม่ของ apple ที่เกิดขึ้นมาในงาน WWCD เย้ย!!! WWDC2019 นั่นเอง (ก็ดูเนิ่นนานมาแล้วนะ) ซึ่งเจ้า binary framework format ใหม่เนี่ย เป็นของเล่นใหม่ตั้งแต่ Xcode11 ละ (คงไม่มีใครใช้ต่ำกว่า Xcode11 แล้วใช่มั้ย 🤔)</p><p>มาถึงตรงนี้อาจจะยังไม่ค่อยเก็ทว่าเป็น binary framework format ใหม่ ???<br>แล้วยังไง??? ยุทธภพเราก็มีการสร้าง framework อยู่ละนี่ งั้นเราไปดูหัวข้อถัดไปกัน ⬇️⬇️⬇️</p><p><strong>xcframework เกิดมาเพื่อสิ่งใด</strong></p><p>ย้อนกลับไปเมื่อ 2000 ปีก่อน (เยอะไป!!!) ย้อนกลับไปก่อนจะมี xcframework เกิดขึ้น ยุทธภพเราได้มีการสร้าง framework ขึ้นมาแล้วแหละ ซึ่งก่อนนี้เรามีสิ่งที่เรียกว่า Universal Static Library หรืออีกชื่อที่เรารู้จักกันก็คือ Fat Framework ซึ่งตัว Fat Framework เนี่ย มันคือของที่เราต้องมา combine framework แต่ละ architecture เอง … อะ อ้าววววว อะไร๊ ทำไมต้องมา combine เอง ปัญหามันอยู่ที่ตรงนี้ทุกคน ค่อยๆ ไล่กันไปทีละ step</p><p>ย้อนกลับไปอีก…ในช่วงที่ M1 ออกมา เวลาที่เรา build framework ออกมาด้วยการเลือก device เป็น simulator แบบในภาพนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*kiKPZapf8W6LcWuXC3IDBg.png" /></figure><p>framework ที่เราได้มาจะเป็น static framework ชะแว้บบบบ ✨✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*_Z749J2jo2IqoboVg-4I4Q.png" /></figure><p>แต่เจ้า framework นี้ปัญหามันคือ พอเราเอาไป embed เข้าโปรเจคต์ เราจะ run ได้แค่บน simulator ที่ &gt;iOS13.7 เพราะตัว simulator นี้จะเป็น x86_64-simulator and arm64-simulator architectures แต่ run บน device จริง framework จะใช้ไม่ได้</p><p>ถ้างั้นๆ ลองเปลี่ยน device ตอน build framework ดูดีกว่า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*vjA6OmeigfxnyX1QEADIbg.png" /></figure><p>ชะแว้บบบบ ได้ framework ใหม่มาแล้ว ซึ่งเป็นตัว static framework เหมือนด้านบนเลย ✨✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*gk_5fXG5iYjgLd9GGbPQmQ.png" /></figure><p>แต่เจ้า framework นี้ก็จะ support แค่การ build บน real device อยู่ดี อะ อ้าว…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16234594&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fconfused-really-gif-16234594&amp;image=https%3A%2F%2Fc.tenor.com%2FhWYtSZDxUfgAAAAd%2Fconfused-really.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/99ea045d508c8becd5d5e82bc0c40155/href">https://medium.com/media/99ea045d508c8becd5d5e82bc0c40155/href</a></iframe><p>แบบแรกก็ไม่ได้ แบบที่สองก็ไม่ได้ แล้วเราจะทำยังไงกันดีล่ะทีนี้… คำตอบก็คือก่อนจะมี xcframework เกิดขึ้น เราต้องทำ fat framework เอง เพื่อให้สามารถ build framework ได้ทั้งบน simulator และเครื่องจริง โดยใช้การ combine 2 framework ด้วย lipo ซึ่งมันก็จะยุ่งยากๆ หน่อย สามารถดูขั้นตอนได้ตามคลิป <a href="https://www.youtube.com/watch?v=OsxzfcUR8GQ&amp;ab_channel=iOSCoderAbhimanyuDaspan">https://www.youtube.com/watch?v=OsxzfcUR8GQ&amp;ab_channel=iOSCoderAbhimanyuDaspan</a></p><p>แต่แล้ว apple ก็เห็นใจชาวยุทธภพของเรา ชีวิตจะยุ่งยากไปทำไม รับ new item ไปล่าบอสใหม่ซะ item ที่ได้รับมาใหม่ก็คือ xcframework นั่นเอง ตัวนี้เราสามารถเขียนเป็น script แล้ว run ได้เลย ซึ่งจะอยู่ในหัวข้อถัดไปนั่นเอง</p><p><strong>วิทยายุทธการสร้าง </strong><strong>xcframework</strong></p><p>สำหรับวิทยายุทธการสร้างมีอยู่ง่ายๆ เลยเพียงแค่เราเอา script ด้านล่างนี้ไปวางไว้ที่ project แล้ว run ด้วยคำสั่ง sh &lt;filename&gt;.sh</p><pre># Set bash script to exit immediately if any commands fail.</pre><pre>set -e</pre><pre># Setup some constants for use later on.</pre><pre>FRAMEWORK_NAME=”TestFramework”</pre><pre>OUTPUT_DIR=”./build”</pre><pre>// สร้าง iOS framework<br>xcodebuild archive \</pre><pre>-scheme ${FRAMEWORK_NAME} \</pre><pre>-configuration Release \</pre><pre>-destination ‘generic/platform=iOS’ \</pre><pre>-archivePath “${OUTPUT_DIR}/${FRAMEWORK_NAME}.framework-iphoneos.xcarchive” \</pre><pre>SKIP_INSTALL=NO \</pre><pre>BUILD_LIBRARY_FOR_DISTRIBUTION=YES</pre><pre><br>//สร้าง iOS Simulator framework</pre><pre>xcodebuild archive \</pre><pre>-scheme ${FRAMEWORK_NAME} \</pre><pre>-configuration Release \</pre><pre>-destination ‘generic/platform=iOS Simulator’ \</pre><pre>-archivePath “${OUTPUT_DIR}/${FRAMEWORK_NAME}.framework-iphonesimulator.xcarchive” \</pre><pre>SKIP_INSTALL=NO \</pre><pre>BUILD_LIBRARY_FOR_DISTRIBUTION=YES</pre><pre><br>// สร้าง xcframework</pre><pre>xcodebuild -create-xcframework \</pre><pre>-framework “${OUTPUT_DIR}/${FRAMEWORK_NAME}.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework” \</pre><pre>-framework “${OUTPUT_DIR}/${FRAMEWORK_NAME}.framework-iphoneos.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework” \</pre><pre>-output “${FRAMEWORK_NAME}.xcframework”</pre><p>จากนั้นก็รอให้ script ทำงานตาม 3 คำสั่งบนไป</p><p>หลังจาก script หยุด run แล้ว มีข้อสังเกตนิดนึงนะ เราต้อง make sure ว่า xcframework มันถูก build success จริงๆ โดยบน terminal เราต้องมีประโยคแบบรูปด้านล่างนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*U-GyppfgwHLWUCdumGsJwQ.png" /></figure><p>และของด้านใน xcframework ก็จะมีตามภาพด้านล่างนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*Og6ZOoRzqI-2Wi33ICo0xw.png" /></figure><p>เพียงแค่นี้เราก็นำเอา TestFramework.xcframework ไป embed ต่อใน project ของเราได้เลย แล้วก็ใช้งาน framework นี้ได้ทั้งบน simulator และ real device แล้ววววววว 👏🏼👏🏼👏🏼</p><p>สำหรับ blog นี้เนื้อหาก็จะมีเพียงเท่านี้ หวังว่าจะเป็น blog ที่มีประโยชน์กับชาวยุทธภพของเราที่ได้เข้ามาอ่าน แล้วเจอกันใหม่ใน blog ฮ้าฟฟฟฟ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c7110c4af65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/finnomena/%E0%B8%AA%E0%B8%B4%E0%B9%88%E0%B8%87%E0%B9%83%E0%B8%94%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%B2%E0%B8%84%E0%B8%B7%E0%B8%AD-xcframework-%E0%B9%83%E0%B8%99%E0%B8%A2%E0%B8%B8%E0%B8%97%E0%B8%98%E0%B8%A0%E0%B8%9E%E0%B8%82%E0%B8%AD%E0%B8%87-ios-dev-2c7110c4af65">สิ่งใดเล่าคือ xcframework ในยุทธภพของ iOS dev</a> was originally published in <a href="https://medium.com/finnomena">Finnomena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s wrong with my Date (Swift)]]></title>
            <link>https://medium.com/finnomena/whats-wrong-with-my-date-swift-b4dec619441d?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4dec619441d</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Fri, 23 Jul 2021 17:30:03 GMT</pubDate>
            <atom:updated>2024-07-30T11:55:34.544Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pspVoGVcsftiU8HgUvJ7uQ.png" /></figure><p>Hello world!!! Today, I will talk about Date object. Although, this object seems to be easy to use, I had faced a problem when I compared two dates which set for Bangkok time zone.</p><p><strong>Let’s see what is the problem I faced and how to fix it.</strong></p><p>First of all, I have a requirement to compare two dates that are exactly the same date. If it is difference, the point will be counted for 1 point. This process similar to when you play a game and it will give a point every login per day.</p><p><em>Guess what I did with my code.</em></p><p>For the first date(Today), I got a current date and converted it to date string with Bangkok time zone because I needed to set time zone to my date and converted my date string to date. I saved my first date to local memory by UserDefaults.</p><p>For the second date (Tomorrow), I still got a current date and converted it like the first date and got the first date from local memory. I used calendar for compare those.</p><p>Next, I will show you step by step in my code and mock first date and tomorrow’s date with timeIntervalSinceReferenceDate</p><p><strong>Step 1:</strong> I created the first date with timeIntervalSinceReferenceDate</p><pre>let date = Date(timeIntervalSinceReferenceDate: 0)<br>print(date)</pre><p>the result: <strong>2001–01–01 00:00:00 +0000</strong></p><p>I have the first date. Then I need to set Bangkok time zone. I search the approach to set date with time zone and they show their code by convert date to date string and set time zone.</p><p><strong>step 2: </strong>I converted my date to date string and set time zone with “Asia/Bangkok”</p><pre>let dateFormatter = DateFormatter()<br>dateFormatter.dateFormat = &quot;yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSSZ&quot;<br>dateFormatter.timeZone = TimeZone(identifier: &quot;Asia/Bangkok&quot;)</pre><pre>let firstDateStr = dateFormatter.string(from: date)<br>print(firstDateStr)</pre><p>the result: <strong>2001–01–01T07:00:00.000+0700</strong></p><p>Wow!!! everything looks good. I had a date with the correct time zone.</p><p>I had the first date(Today) and then I needed to mock tomorrow’s date with timeIntervalSinceReferenceDate. So my first date string was 2001–01–01 and time was 07.00 am. Then, I have to create tomorrow time and add 17 hours.</p><p><strong>Step 3</strong>: I created my date and added 17 hours and converted it to date string.</p><pre>let calendar = Calendar.current<br>let tomorrow = calendar.date(byAdding: .hour, value: 17, to: date!)!<br>let tomorrowDateStr = dateFormatter.string(from: tomorrow)<br>print(tomorrowDateStr)</pre><p>the result: <strong>2001–01–02T00:00:00.000+0700</strong></p><p>🤩🤩🤩 Now I had tomorrow’s date and I needed to compare two dates follow a requirement.</p><p>Oh wait! I cannot use date string. I need to use calendar to compare the same date with compare(_:to:toGranularity:) function and this func requires date object so I need to convert my date string to date object</p><p><strong>Step 4:</strong> Convert first date string and tomorrow’s date string to date object</p><pre>let firstDate = dateFormatter.date(from: firstDateStr)!<br>let tomorrowWithTimezone = dateFormatter.date(from: firstDateStr)!<br>let isSameDate = calendar.isDate(firstDate, equalTo: tomorrowWithTimezone, toGranularity: .day)<br>print(isSameDate)</pre><p>the result: <strong>true</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E05N2vOMutOs-J5XnCeTgg.jpeg" /></figure><p>What? Wait. What happen? What’s wrong with my first date and the tomorrow’s date. Why those are the same date?</p><p>I tried to find out what’s wrong with my date and I found the answer from someone said when you convert string to date, <strong><em>time zone will be always to UTC.</em></strong></p><p>In my head, “<strong>Stupid dog(date)</strong>! <strong>You make me look bad!</strong>”, this quote from cartoon network. 😂😂😂</p><p><strong>And how I can fix it? Let’s see the solution.</strong></p><p>Now, I knew If I convert my date string to date object, it will be always to UTC even time zone in date string was converted. I knew that I must use calendar to compare two dates. So I think, I used my date and set Bangkok time zone to calendar and compared them. Let’s see my final code.</p><pre>let date = Date(timeIntervalSinceReferenceDate: 0)<br>var calendar = Calendar.current<br>let tomorrow = calendar.date(byAdding: .hour, value: 17, to: date)!<br>calendar.timeZone = TimeZone(identifier: &quot;Asia/Bangkok&quot;) ?? .current<br>let isSameDate = calendar.isDate(date, equalTo: tomorrow, toGranularity: .day)<br>print(isSameDate)</pre><p>the result: <strong>false</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*bVzJknhsGatXFOgSYBL9vQ.png" /></figure><p><strong>Keep in mind:</strong></p><ul><li>When you get date, time zone will be always UTC.</li><li>When you convert date from date string, time zone will be always UTC.</li><li>If you need to compare date with time zone. You can use calendar and set your time zone to calendar.</li></ul><p>Let’s play with date object/calendar and time zone. 💪🏻💪🏻💪🏻</p><p>I hope this blog will give the benefit for you guys. If you have any question, feel free to comment below. 🤗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4dec619441d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/finnomena/whats-wrong-with-my-date-swift-b4dec619441d">What’s wrong with my Date (Swift)</a> was originally published in <a href="https://medium.com/finnomena">Finnomena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ทำตัวเหล่ท่อไปกับ Higher order functions in Swift]]></title>
            <link>https://medium.com/finnomena/%E0%B8%97%E0%B8%B3%E0%B8%95%E0%B8%B1%E0%B8%A7%E0%B9%80%E0%B8%AB%E0%B8%A5%E0%B9%88%E0%B8%97%E0%B9%88%E0%B8%AD%E0%B9%84%E0%B8%9B%E0%B8%81%E0%B8%B1%E0%B8%9A-higher-order-functions-in-swift-591c69fe7c80?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/591c69fe7c80</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[higher-order-function]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Fri, 11 Jun 2021 08:35:13 GMT</pubDate>
            <atom:updated>2021-06-11T08:35:13.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TM9OGlh9XvrsR7TgmR4gQ.png" /></figure><p>หวัดดีชาวโลก นี่เราเดินทางเข้าสู่อีกครึ่งปีของปี 2021 แล้วหรอเนี่ย เร็วมากกกกก เอาล่ะมาเข้าเรื่องกันเถอะเนอะ สำหรับ blog นี้ก็จะตามหัวข้อเลยนะ เราจะมาพูดถึง Higher order functions in Swift ซึ่งเนื้อหาจะมีอะไรยังไงบ้าง ไปดูกันโลดดดดดด</p><h4><strong>สิ่งที่จะพูดถึงในวันนี้</strong></h4><ul><li>อะไรคือ Higher order functions</li><li>ประโยชน์ของ Higher order functions</li><li>Higher order functions ที่เรานิยมนำมาใช้กันมากที่สุด</li></ul><p>มาเริ่มกันที่หัวข้อแรกกันเลยดีกว่า</p><h4><strong>อะไรคือ </strong><strong>Higher order functions</strong></h4><p>สำหรับชาว iOS ที่เขียนภาษา Swift จะมีคำอธิบายแค่ 2 ข้อเท่านั้น สั้นๆ กระชับ และเข้าใจง่ายแน่นอน<br>1. function ที่รับ argument มาเป็น function หรือ closures<br>2. function ที่มีการ return มาเป็น function หรือ closures</p><p>เนี่ยยยยยมีแค่นี้เลย เพียง 2 ข้อสั้นๆ กระชับเข้าใจได้ง่าย 😁😁😁</p><p>มาดูตัวอย่างที่เขียนกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*No3bedOoCNzjuE_j" /></figure><p>จะเห็นว่า function combineUserData จะเป็น Higher order functions เพราะมีการรับ function เข้ามาเป็น argument ซึ่ง function ที่จะถูกส่งเข้ามาจะเป็นการรับ string 2 ตัวเข้ามาและทำอะไรซักอย่าง แล้ว return ออกมาเป็น string และจากโค้ดจะได้ผลลัพธ์ตามรูปด้านล่างนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*lKMD0GVi9j__QQm7" /></figure><h4><strong>ประโยชน์ของ </strong><strong>Higher order functions</strong></h4><ul><li>โค้ดจะอ่านง่ายได้จาก function เลย และโค้ดจะ clean และ clear มาก</li><li>ง่ายต่อการ reuse กับ function อื่นๆ</li><li>และข้อสุดท้ายสำคัญมากๆ ใช้แล้วจะรู้สึกเหล่ท่อมากๆ 😂😂😂</li></ul><h4><strong>Higher order functions ที่เรานิยมนำมาใช้กันมากที่สุด</strong></h4><ul><li>map</li><li>compactMap</li><li>flatMap</li><li>reduce</li><li>sorted</li><li>filter</li></ul><p>มาเริ่มดูกันที่ตัวแรกก่อนเล้ยยยยยย</p><ul><li><strong>map</strong> จะเป็นการเปลี่ยน element แต่ละตัวของ array เดิม ใน closure แล้วส่งค่าของ array ใหม่กลับมา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/0*-YD8fzWxyU0Wj_X4" /></figure><p>ตัวอย่างการใช้ <strong>map</strong></p><pre>let countries: [String] = [&quot;thailand&quot;, &quot;india&quot;, &quot;england&quot;, &quot;france&quot;, &quot;usa&quot;]</pre><p>จากตัวอย่างข้อมูลด้านบน ถ้าหากเราต้องการให้ตัวหนังสือเป็นตัวใหญ่ทั้งหมด แบบไม่ใช้ Higher order functions ก็คงจะเขียน for loop ในลักษณะนี้กันเนอะ</p><pre>var uppercasedWordsForLoop: [String] = [String]()<br>for country in countries {<br>   uppercasedWordsForLoop.append(country.uppercased())<br>}</pre><p>แต่ถ้าหากว่าเราจะใช้ Higher order functions ล่ะจะเป็นยังไง</p><pre>let uppercasedWords = countries.map { $0.uppercased() }</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_PlkFAK_m3J-2QLC25SJQ.png" /></figure><p>จะเห็นได้ว่าตอนเราใช้ for loop โค้ดจะค่อนข้างยาว แถมยังต้องสร้าง array อีกตัวมา append element ทีละตัวด้วย และการใช้ map โค้ดจะสั้นกระชับ และ clear ด้วย</p><ul><li><strong>compactMap</strong> จะเป็น function ที่คล้ายกันกับ map เลย เพียงแต่ compactMap จะ returns array ที่จะไม่มีค่า null</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/0*WZxKM0R_odukKJiN" /></figure><p>ตัวอย่างการใช้ compactMap</p><pre>let countries: [String?] = [&quot;thailand&quot;, nil, nil, &quot;india&quot;, &quot;england&quot;, nil, &quot;france&quot;, &quot;usa&quot;]<br>let map = countries.map { $0?.uppercased() }<br>let compactMap = countries.compactMap { $0?.uppercased() }</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vp1GOQCrFAN_v3ePACRoBw.png" /></figure><p>จากผลลัพธ์จะเห็นว่าถ้าหากเราใช้ map ตัว array ของเราจะยังคงมี element ที่เป็น null อยู่ด้วย แต่หากใช้ compact map เราจะได้ array ที่ไม่มีค่า null นั่นเอง</p><ul><li><strong>flatMap</strong> จะช่วยเราจัดการกับพวก nested array หากเราใช้ flatMap กับ nested array ใดๆ จะทำให้ array นั้นกลายเป็น array 1 มิติ และเรายังใช้ flatMap เหมือน compactMap ด้วย คือค่าใน array จะไม่มี null นั่นเอง</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/0*6cxR-ESqalF6bYGF" /></figure><p>ตัวอย่างการใช้ flatMap</p><pre>let countries: [[String]] = [[&quot;thailand&quot;, &quot;india&quot;], [&quot;england&quot;, &quot;france&quot;, &quot;usa&quot;]]<br>let flatMap = countries.flatMap { $0 }</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQPAsoytJeVIHWk_4_R3mg.png" /></figure><ul><li><strong>reduce</strong> เป็น function ที่ให้เรา combine ทุก elements ใน array แล้ว return ข้อมูลบางอย่างออกมาด้วย type อะไรก็ได้ (Generic)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/0*Evqcm14Jw0MSvvRR" /></figure><p>ตัวอย่างการใช้ reduce (แบบเต็ม)</p><pre>let numbers: [Int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<br>let sum = numbers.reduce(0, { x, y in<br>    return x + y<br>})</pre><p>ตัวอย่างการใช้ reduce (แบบสั้น)</p><pre>let sum2 = numbers.reduce(0, { $0 + $1 })</pre><p>ตัวอย่างการใช้ reduce (แบบสั้นยิ่งกว่าาาาา)</p><pre>let sum3 = numbers.reduce(0, +)</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*ORzdwwPiMWHoULyGxPhTAA.png" /></figure><ul><li><strong>sorted</strong> เป็น function ที่ทำงานตามชื่อเลย ก็คือการเรียงข้อมูลใร array นั่นเอง</li></ul><p>ตัวอย่างการใช้ sorted</p><pre>let toSort = [5, 3, 8, 2, 10]</pre><pre>let sorted = toSort.sorted()</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*GtXK5EBy_m5kFUp_pv2JIg.png" /></figure><p>จากผลลัพธ์ ถ้าหากเราเรียกใช้ sorted แบบด้านบนตัวเลขจะถูกเรียงจากน้อยไปหามาก แต่ถ้าหากเราต้องการให้เรียงจากมากไปน้อยล่ะ จะเขียนยังไง ไปดูกัน</p><p>ตัวอย่างการใช้ sorted เรียงจากมากไปน้อย</p><pre>let sortedShortHand = toSort.sorted { (num1, num2) -&gt; Bool in<br>    return num1 &gt; num2<br>}</pre><p>ตัวอย่างการใช้ sorted เรียงจากมากไปน้อย (แบบสั้น)</p><pre>let sortedShorterHand = toSort.sorted { $0 &gt; $1 }</pre><p>ตัวอย่างการใช้ sorted เรียงจากมากไปน้อย (แบบสั้นยิ่งกว่าาาาา)</p><pre>let sortedShortestHand = toSort.sorted(by: &gt;)</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*tzbDgEhLLpy4s5qK5xWryw.png" /></figure><ul><li><strong>filter </strong>จะเป็นการ filter element ของ array เดิมด้วยเงื่อนไขที่กำหนด และใน closure จะส่งค่าของ array ใหม่กลับมา เช่น การหาเลขคู่/คี่ ใน array ของตัวเลข เป็นต้น</li></ul><p>ตัวอย่างการใช้ filter</p><pre>let numbers: [Int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<br>let filter = numbers.filter { $0 % 2 == 0 }</pre><p>ผลลัพธ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*juSVyl7qwRoD8LJWgsV1Xg.png" /></figure><p>จะเห็นได้ว่าจากตัวอย่างทั้งหมด แต่ละ function จะทำให้เราเขียนโค้ดได้สั้นกระชับมากขึ้น และตัว function ก็ค่อนข้าง clear เมื่อได้อ่าน ซึ่งมันจะเป็นผลดีต่อเราและทีมของเราแน่นอน และที่สำคัญเขียนออกมาแล้วยังเหล่ท่อไปอี้กกกกก</p><p>สำหรับ blog นี้เนื้อหาก็จะมีเพียงเท่านี้ หวังว่าจะเป็น blog ที่มีประโยชน์กับทุกคนที่ได้เข้ามาอ่าน แล้วเจอกันใหม่ใน blog ฮ้าฟฟฟฟ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=591c69fe7c80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/finnomena/%E0%B8%97%E0%B8%B3%E0%B8%95%E0%B8%B1%E0%B8%A7%E0%B9%80%E0%B8%AB%E0%B8%A5%E0%B9%88%E0%B8%97%E0%B9%88%E0%B8%AD%E0%B9%84%E0%B8%9B%E0%B8%81%E0%B8%B1%E0%B8%9A-higher-order-functions-in-swift-591c69fe7c80">ทำตัวเหล่ท่อไปกับ Higher order functions in Swift</a> was originally published in <a href="https://medium.com/finnomena">Finnomena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to set image and label in trailing swipe action with custom font (iOS11)]]></title>
            <link>https://forzfilm.medium.com/how-to-set-image-and-label-in-trailing-swipe-action-with-custom-font-ios11-4a49d4794669?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a49d4794669</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[tableviews]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Mon, 08 Mar 2021 04:34:20 GMT</pubDate>
            <atom:updated>2021-03-08T04:34:20.500Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBFuLiXdcHpGZzEh62zrpA.png" /></figure><p>Hello world!!! Today I will talk about trailing swipe action in UITableView. This feature will help user actions easily within list view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*lQXzKHnsBxCB_N7drX-7eQ.gif" /></figure><h4><strong>The content in this blog includes</strong></h4><ul><li>What is trailing swipe action</li><li>Custom font problem</li><li>How to fix it</li></ul><h4><strong>What is </strong><strong>trailing swipe action</strong></h4><p>For each row in table view, user can swipe horizontal from the right of list view to show action menu and we can custom them.</p><blockquote><strong>Technically, we need to use</strong> tableView(_:trailingSwipeActionsConfigurationForRowAt:) in table view delegate</blockquote><blockquote>We can use<a href="https://developer.apple.com/documentation/uikit/uiswipeactionsconfiguration">UISwipeActionsConfiguration</a> and <a href="https://developer.apple.com/documentation/uikit/uicontextualaction">UIContextualAction</a> to return swipe actions</blockquote><h4>Custom font problem</h4><p>At first, I have a requirement from product owner that they need to show trailing swipe action in our list view, I think “Oh it’s so easy, Apple has provided this action for us” but I was wrong. 😢😢😢</p><p>If you set title and image in UIContextualAction, you will get screen like below picture that it look so fine, right?</p><p>But I got the problem which is I can’t customize font in UIContextualAction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*8bB7_dRbJuzsmVnx6c4zkg.png" /></figure><p>I try to find the solution and finally I found the way to solved this problem.</p><h4>How to fix it</h4><ol><li>I created a label with custom font and image</li><li>I combined label and image to one image and set the image to UIContextualAction</li></ol><p><strong><em>let’s see the code</em></strong></p><ul><li>The part of UITableViewDelegate</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fea26db3223bb9fbe6d982cd82a9a6d0/href">https://medium.com/media/fea26db3223bb9fbe6d982cd82a9a6d0/href</a></iframe><ul><li>The part of combination between label and image</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ea4fbee1bed10b0803cc4a8aa20e062/href">https://medium.com/media/0ea4fbee1bed10b0803cc4a8aa20e062/href</a></iframe><p><strong>The result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*6SMA8tuhfqnkC8no1AR_sQ.png" /></figure><p>Let’s try it yourself!</p><p>I hope this blog will give the benefit for you guys. If you have any question, feel free to comment below. 🤗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a49d4794669" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[วิธีการนำ Equatable ไปใช้แบบเหล่ท่อใน Swift]]></title>
            <link>https://forzfilm.medium.com/%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%99%E0%B8%B3-equatable-%E0%B9%84%E0%B8%9B%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B9%80%E0%B8%AB%E0%B8%A5%E0%B9%88%E0%B8%97%E0%B9%88%E0%B8%AD%E0%B9%83%E0%B8%99-swift-13eb725a1984?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/13eb725a1984</guid>
            <category><![CDATA[equatable]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[protocol]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Fri, 29 Jan 2021 05:46:45 GMT</pubDate>
            <atom:updated>2021-01-29T05:46:45.925Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHXTLx6Eex2QWlD7G6JrbA.png" /></figure><p>สวัสดีชาวโลก และสวัสดีปีใหม่ปี 2021 🎉🎉🎉 (ก็ช้าไป๊ จะหมดเดือนแรกอยู่ละ) วันนี้จะมาประเดิม blog แรกประจำปี 2021 ด้วยเรื่อง Equatable ในภาษา swift จ้า ซึ่งที่คิดไว้น่าจะเป็น blog สั้นๆ แต่มีประโยชน์แน่นอน 100%</p><p><strong>สิ่งที่จะพูดถึงจะมีดังนี้</strong></p><ul><li>Equatable คืออะไร</li><li>น้อมนำ Equatable ไปใช้</li></ul><p>เอาล่ะ มาเริ่มกันที่หัวข้อแรกกันก่อนเลย <strong><em>Equatable คืออะไร</em></strong></p><p>ใน document ของ apple กล่าวว่า</p><blockquote>A type that can be compared for value equality.</blockquote><p>แปลตรงๆ เลยนะ ก็คือ type ที่เราสามารถเอาไปเปรียบเทียบค่าได้…แค่นี้เลย…แค่นี้จริงๆ 😂 😂 😂 คำนิยามที่สั้นกริบ แต่…มันไม่ได้ง่ายขนาดนั้น เพราะเจ้า Equatable เนี่ย ตัวมันเองเป็น protocol ซึ่งการที่จะใช้ Equatable เราก็จะต้อง conform มาก่อน ดังนั้นเราจึงใช้ Equatable ได้ทั้งกับ class, struct หรือแม้แต่ enum ดังนั้นอย่ารอช้าเราจะไปที่หัวข้อต่อไปกันเล้ยยยยย</p><p><strong><em>น้อมนำ Equatable ไปใช้</em></strong></p><p>อย่างที่ได้เกริ่นไปในหัวข้อก่อนหน้านี้ว่าเราสามารถใช้ Equatable ได้ทั้งกับ class, struct หรือแม้แต่ enum เพราะฉะนั้นส่วนนี้จะขอเลือกตัวอย่างการใช้งานกับ struct และ enum มาให้ดู เพราะ stuct กับ class จะเหมือนกันอยู่แล้ว ส่วน enum จะมีท่าพิเศษเพิ่มมาหน่อย</p><p><em>การใช้งาน Equatable กับ struct</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6asbyD8Jzpnh7_M9y22eGg.png" /></figure><p><em>ผลลัพธ์ที่ได้<br></em>false<br>true</p><p><strong>หมายเหตุ</strong>: เราไม่จำเป็นต้องเอาทุก property ใน struct ไปเปรียบเทียบนะ แล้วแต่ค่าที่เราต้องการจะเปรียบเทียบเลย</p><p><em>การใช้งาน Equatable กับ enum</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjWqVm1vgi62jQBU-DR6bQ.png" /></figure><p><em>ผลลัพธ์ที่ได้<br></em>true<br>false<br>false<br>true</p><p>จากตัวอย่างของ enum จะเป็นการเปรียบเทียบ associated values ใน enum เลย</p><p>ส่วนใหญ่เจ้าของ blog จะนำไปใช้ตอนที่ต้องทำ unit test เพื่อ compare ค่าระหว่าง object 2 ตัว หรือ state ของ enum ที่ return กลับมาว่าตรงกันมั้ย และนี่แหละคือประโยชน์ของตัว Equatableนั่นเอง 👏🏻👏🏻👏🏻</p><p>และสำหรับ blog นี้ก็มีเนื้อหาเพียงเท่านี้ หวังว่า blog นี้จะเป็นประโยชน์กับคนที่ได้เข้ามาอ่านนะ แล้วแจกันใหม่ใน blog หน้า 😬 😬 😬</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13eb725a1984" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ซ่อนข้อมูลลับตอน switch app ใน iOS แบบหล่อเท่ ด้วย Snapshot image]]></title>
            <link>https://forzfilm.medium.com/%E0%B8%8B%E0%B9%88%E0%B8%AD%E0%B8%99%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5%E0%B8%A5%E0%B8%B1%E0%B8%9A%E0%B8%95%E0%B8%AD%E0%B8%99-switch-app-%E0%B9%83%E0%B8%99-ios-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%AB%E0%B8%A5%E0%B9%88%E0%B8%AD%E0%B9%80%E0%B8%97%E0%B9%88-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-snapshot-image-dbec65fb0b4b?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbec65fb0b4b</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[app-delegate]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Mon, 16 Nov 2020 09:48:39 GMT</pubDate>
            <atom:updated>2020-11-16T09:48:39.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pspVoGVcsftiU8HgUvJ7uQ.png" /></figure><p>สวัสดีชาวโลก กลับมาพบกันอีกแล้วในปีนี้ สำหรับ blog นี้ก็เป็น blog ที่ 4 ของปีนี้แล้ว เป็นปีที่ปล่อย blog ออกมาเยอะสุดละ (ไม่รู้เพราะว่างหรือเรามันเทพขึ้น ฮันน่อวววว)</p><p>สำหรับ blog นี้ก็ตามหัวข้อเลยเนอะ เราจะพาทุกคนซ่อนข้อมูลแอพตอน switch app ด้วยสิ่งที่เรียกว่า Snapshot image (คิดว่ามันเรียกว่างี้นะ)</p><p><strong>สำหรับสิ่งที่จะพูดถึงใน blog นี้ก็จะมี</strong></p><ul><li>Snapshot image คืออะไร</li><li>การนำไป implement ใน project</li></ul><p>มาเริ่มที่หัวข้อแรกกันเลย <strong>Snapshot image คืออะไร</strong></p><p>พอได้ยินชื่อแล้ว อาจจะมีคนงงๆ ว่าสิ่งนี้คืออะไร อยากให้ทุกคนนึกถึงพวกแอพธนาคาร เวลาที่เรา switch app นะ ละแอพธนาคารจะมีเหมือนหน้ากากมาบังไว้ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*vfztENJE2M5k711uC4r8lA.png" /></figure><p>เอาล่ะ พอได้รู้จักและเห็นภาพกันแล้ว เรามาดูโค้ดกันเลยว่ามีส่วนไหนที่เราต้องไป implement ใน project บ้าง</p><p><strong>การนำไป implement ใน project</strong></p><p>ในส่วนของไฟล์ AppDelegate เราจะ implement code ใน <br>func applicationWillResignActive(_ application: UIApplication) และ <br>func applicationDidBecomeActive(_ application: UIApplication)</p><p>มาดูโค้ดในส่วนของ func applicationWillResignActive(_ application: UIApplication) กันก่อนเลย</p><pre>func applicationWillResignActive(_ application: UIApplication) {</pre><pre>  let backgroundImageView = UIImageView()</pre><pre>  backgroundImageView.tag = 111</pre><pre>  backgroundImageView.image = UIImage(named: &quot;irene&quot;)</pre><pre>  guard let window = window else { return }</pre><pre>  backgroundImageView.frame = window.frame</pre><pre>  window.addSubview(backgroundImageView)</pre><pre>  window.bringSubviewToFront(backgroundImageView)</pre><pre>  backgroundImageView.alpha = 0</pre><pre>  UIView.animate(withDuration: 0.2, animations: {</pre><pre>    backgroundImageView.alpha = 1</pre><pre>  })</pre><pre>}</pre><p>จากโค้ด func applicationWillResignActive จะถูกเรียกทุกครั้งที่ user ทำการ switch app (become inactive)<br>1. เราจะสร้าง image view ขึ้น <br>2. เพิ่มเลข tag ให้กับ image view ที่เราพึ่งสร้างขึ้นมาในตย. จะเป็น 111<br>3. ให้ image view มี size เดียวกันกับ frame ของ window<br>4. add image view เข้าไปเป็น subview ของ window และมาอยู่ด้านหน้าสุด<br>5. set alpha เป็น 0 ไว้ และใน animate ค่อยให้ alpha เป็น 1</p><p>จากนั้นมาดูโค้ดส่วน func applicationDidBecomeActive(_ application: UIApplication) กัน</p><pre>func applicationDidBecomeActive(_ application: UIApplication) {<br>  guard let background = window?.viewWithTag(111) else { return }</pre><pre>  UIView.animate(withDuration: 0.2, animations: {</pre><pre>    background.alpha = 0</pre><pre>  }, completion: { _ in</pre><pre>    background.removeFromSuperview()</pre><pre>  })<br>}</pre><p>จากโค้ด func applicationDidBecomeActive จะถูกเรียกทุกครั้งที่ user ทำการ switch app กลับมาที่ app เรา (become active)<br>1. เราจะ get view จากเลข tag ที่เรากำหนดไว้ก่อนซึ่งก็คือ 111<br>2. ใน animate เราจะ set alpha ให้เป็น 0<br>3. และเมื่อ animate เสร็จ เราจะ remove view นี้ออกจาก superview</p><p>implement แค่นี้เราก็จะได้ Snapshot image ไว้บังข้อมูลลับแบบหล่อเท่แล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*qvHob68hA8ddmSOwG96Hxw.gif" /></figure><blockquote>NOTE: สำหรับคนที่ใช้ SceneDelegate จะต้อง implement ใน <br>func sceneDidBecomeActive(_ scene: UIScene) และ <br>func sceneWillResignActive(_ scene: UIScene)</blockquote><p>สำหรับ blog นี้ก็มีเนื้อหาเพียงเท่านี้หวังว่าจะเป็นประโยชน์กับคนที่ได้เข้ามาอ่าน และนำท่าหล่อเท่แบบนี้ไปใช้ในแอพตัวเอง 😬😬😬</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbec65fb0b4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การใช้ typealias และ associatedtype ใน Swift Language]]></title>
            <link>https://forzfilm.medium.com/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89-typealias-%E0%B9%81%E0%B8%A5%E0%B8%B0-associatedtype-%E0%B9%83%E0%B8%99-swift-language-17c445e651b1?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/17c445e651b1</guid>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Sun, 23 Aug 2020 05:36:16 GMT</pubDate>
            <atom:updated>2020-08-24T03:26:15.357Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cM2WmqPMann-x4vRtHpxrg.png" /></figure><p>สวัสดีชาวโลก กลับมาพบกันอีกแล้วในรอบครึ่งปี blog นี้ เกิดขึ้นจากการที่เราสับสนกันระหว่าง typealias กับ associatedtype เลยอยากเขียน blog นี้ขึ้นมา เพื่อย้ำความจำตัวเอง และให้คนที่เข้ามาอ่านได้รู้จักทั้ง 2 อย่างนี้ด้วย ถ้าหากไม่เคยรู้จักมาก่อน แต่ถ้าอ่านแล้วยังงงๆ ไม่เข้าใจอยู่ ตามสโลแกนเดิมจาก blog ที่แล้วเลย มาทำงานที่ FINNOMENA ดิ เดี๋ยวเราสอนให้ 😁😁😁</p><p><strong>สำหรับสิ่งที่จะพูดถึงในวันนี้ก็จะมี</strong></p><ul><li>typealias คืออะไร</li><li>ตัวอย่างการใช้ typealias</li><li>associatedtype คืออะไร</li><li>ตัวอย่างการใช้ associatedtype</li></ul><p><strong>typealias คืออะไร</strong></p><p>typealias ก็คือสิ่งที่เราจะตั้งชื่อใหม่ให้กับ type ที่มีอยู่แล้ว ไม่ว่าจะเป็น</p><ul><li>built-in type เช่น Int, String เป็นต้นใบ</li><li>User-defined types เช่น class, struct, protocol เป็นต้นไม้</li><li>Complex types เช่น closures เป็นต้นอะไรดี</li></ul><p>หลังจากที่เราตั้งชื่อให้กับ type เดิมเราแล้ว เราก็จะสามารถเรียกชื่อที่เราตั้งให้แทน type เดิมได้เลย</p><p><strong>ตัวอย่างการใช้ typealias</strong></p><ul><li>การใช้ typealias กับ built-in type</li></ul><pre>typealias SpouseFirstName = String</pre><pre>typealias SpouseID = Int<br></pre><pre>let name: SpouseFirstName = &quot;Ravin&quot;</pre><pre>let id: SpouseID = 1</pre><ul><li>การใช้ typealias กับ User-defined types</li></ul><pre>protocol AppDelegateViewModelInput {<br>  func setUserDefaultForUITesting()<br>}</pre><pre>typealias Input = AppDelegateViewModelInput</pre><pre>class AppDelegateViewModel: Input {<br>  func setUserDefaultForUITesting() {</pre><pre>  }<br>}</pre><ul><li>การใช้ typealias กับ Complex types</li></ul><pre>typealias ViewControllerCallback = (UIViewController) -&gt; Void</pre><pre>var onViewControllerShowed: ViewControllerCallback = { _ in }</pre><p>มาถึงตรงนี้ทุกคนพอจะเห็นประโยชน์ของการใช้ typealias แล้วใช่มั้ย สิ่งนี้มันเกิดขึ้นเพื่อให้โค้ดเราอ่านได้ง่ายขึ้น และแสดงให้เห็นสิ่งที่เราจะกล่าวถึงได้อย่างชัดเจนและเป็นภาษาคน</p><p><strong>associatedtype คืออะไร</strong></p><p>ส่วนนี้เราจะพูดถึง Protocols with Associated Types ซึ่ง associatedtype เป็นตัวแปรที่จะถูกใช้ใน protocol และตัวแปรใน protocol นั้นๆ สามารถรับ type อะไรเข้ามาก็ได้ เป็นเหมือน placeholder ของ type นั้นๆ ไว้ ซึ่งการใช้งานแบบนี้เป็นหนึ่งในเรื่อง Generics นั่นเอง จริงๆ Generics เป็นเรื่องใหญ่ๆ ที่มีหลายส่วน 1 ในนั้น เราเคยเขียน blog ไว้ เป็นของ Generics function สามารถอ่านได้<a href="https://medium.com/@pattaravadeeluamsomboon/generics-function-in-swift-a011d3215b49">ที่นี่</a></p><p><strong>ตัวอย่างการใช้ associatedtype</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0C-DBcz9NVROnmW8UkQ8fA.png" /></figure><p>จากในโค้ดจะเห็นว่าเรามี protocol ที่ชื่อว่า Student และใน Student จะมี idList ซึ่งเป็น array ของ associatedtype ที่เราตั้งชื่อว่า ID นั่นเอง และเมื่อเรามาดูใน struct Room1 ที่ conform Student protocol มา เราจะเห็นว่า idList ที่ถูกใส่เข้าไปจะเป็น string array และ room1 ก็สามารถเรียก func show ที่แสดงของที่อยู่ใน idList ได้ พอมาดู struct Room2 ที่ conform Student protocol เหมือนกับ Room1 แต่สิ่งที่ต่างกันคือ idList ใน Room2 จะเป็น int array และสามารถเรียก func show ได้เหมือนกัน</p><p>นี่คือประโยชน์ของ Generics เลยแหละ ทำให้ทุกอย่างยืดหยุ่นได้ บาง class จะ conform protocol ได้เหมือนกันอยู่แล้ว แต่ตัวแปรดันคนละ type จากที่เราอาจต้องเขียน protocol มาเพิ่มเพื่อ support แต่ละ type ให้ตัวแปรนั้น เราก็สามารถใช้ associatedtype นี่แหละได้เลย 👏🏻👏🏻👏🏻</p><p>เอาล่ะมาถึงตรงนี้แล้ว หวังว่าทุกคนจะพอเข้าใจ 2 สิ่งนี้ได้มากขึ้นและไม่จำสับสนกันแบบเรานะ 😂😂😂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17c445e651b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[@escaping ตัวร้ายกับนาย closures ใน Swift Language]]></title>
            <link>https://forzfilm.medium.com/escaping-%E0%B8%95%E0%B8%B1%E0%B8%A7%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%A2%E0%B8%81%E0%B8%B1%E0%B8%9A%E0%B8%99%E0%B8%B2%E0%B8%A2-closures-%E0%B9%83%E0%B8%99-swift-language-869e948d002c?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/869e948d002c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[closures-functions]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 15:06:31 GMT</pubDate>
            <atom:updated>2020-04-17T15:15:48.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eaeetv5KS3uZu4B9E892Ig.png" /></figure><p>สวัสดีชาวโลก วันนี้มาด้วย blog ภาษาไทย เพราะเป็นเรื่องที่ค่อนข้างเข้าใจได้ยาก ถ้าเขียนเป็นภาษาอังกฤษอาจจะงงทั้งคนอ่านและคนเขียน แต่ถ้าเขียนเป็นไทยก็จะยังงงทั้งคู่อยู่ดี 🤣🤣🤣 หยอกๆ เอาล่ะมาเข้าเรื่องกันเลยดีกว่า วันนี้จะมาเขียนเรื่องของ @escaping คนเขียน swift lang น่าจะเคยเห็นกันมาบ้างตอนที่ต้องใช้ closure แต่ถ้าไม่เคยเขียน swift คงงงว่านี่มันคืออะไร closures คืออะไร @escapingคืออะไร ตอนไหนล่ะเราถึงจะต้องใส่ @escapingเข้าไปใน closures แต่ถ้าอ่าน blog นี้จบ ไม่ว่าจะเคยเขียนหรือไม่เคยเขียน swift ก็จะพอนึกออกเลยแหละว่าสิ่งนี้คืออะไร แต่ถ้านึกไม่ออกมาทำงานที่ FINNOMENA ดิ เดี๋ยวเราสอนให้ 😁😁😁</p><p><strong>เอาล่ะมาดูสิ่งที่จะพูดถึงใน blog นี้กัน</strong></p><ul><li>Closures คือสิ่งใด</li><li>@nonescaping ทำงานยังไง ใช้ตอนไหน</li><li>@escaping ทำงานยังไง ใช้ตอนไหน</li></ul><h4>Closures คืออะไร</h4><p>ขอมามุกเดิมก่อนเลย แปะ doc ที่ได้กล่าวไว้</p><blockquote><em>Closures</em> are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.</blockquote><p>จาก doc เราสามารถจินตนาการตามได้ว่า closures มันก็คล้ายกับ block ใน c และ obj-c หรือ lambdas ใน programming language อื่นๆ นั่นแหละ แต่ขออธิบายแบบภาษาบ้านๆ เพิ่มนิดนึงตรง self-conself-contained blocks of functionality เนี่ย มันก็คือการที่เรา <strong>ส่ง function เข้าไปเป็น 1 ใน parameter ของอีก function</strong> ได้เลยยังไงล่ะ แล้วทีนี้ @nonescaping กับ @escaping เนี่ยถ้าเราจะส่ง parameter เข้ามาเป็น function ก็อาจจะต้องเขียน @escaping หรืออาจไม่ต้องเขียนก็ได้ แล้วแต่การทำงานซึ่งจะพูดถึงในหัวข้อถัดไป</p><h4>@nonescaping ใช้ตอนไหน ทำงานยังไง</h4><p>จากด้านบนที่เราได้รู้ไปแล้วเนอะว่า closures คืออะไร ทีนี้เรามาดูกันบ้างว่าตัว @nonescaping จะเอาไปใช้ตอนไหน และทำงานยังไง สำหรับตัว @nonscaping เราไม่จำเป็นต้องเขียนลงใน function เพราะจะถูก default ไว้อยู่แล้ว เดี๋ยวลองดูตามตัวอย่างโค้ดด้านล่างแล้วคิดตามนะ</p><ul><li>step 1 เราเรียก calculateBMI โดยจะส่งความสูง, น้ำหนัก และ result เข้าไปซึ่งถูกรับเป็น function ที่จะ return ค่า bmi มาให้</li><li>step 2 ใน calculateBMI function จะคำนวณ bmi</li><li>step 3 result function จะถูกเรียกเป็น callback และแนบค่า bmi กลับมาด้วย</li><li>step 4 เอาค่า bmi มาใช้</li></ul><p>จะเห็นว่าตัว result จะถูกเรียก callback กลับมาตั้งแต่ใน body ของ calculateBMI function แล้ว การทำงานทุกอย่างก็คือจบแล้ว</p><p><strong><em>ตัวอย่างที่ 1</em></strong></p><pre>override func viewDidLoad() {</pre><pre>   super.viewDidLoad()<br>   // Step 1</pre><pre>   calculateBMI(height: 1.58, weight: 44.5, result: { bmi in</pre><pre>       // Step 4<br>       print(bmi)<br>   })</pre><pre>}</pre><pre>func calculateBMI(height: Float,<br>                  weight: Float,<br>                  result: (_ value: Float) -&gt; Void) {<br>     // Step 2<br>     let bmi = weight/pow(height, 2)</pre><pre>     // Step 3<br>     result(bmi)</pre><pre>}</pre><h4>@escaping ใช้ตอนไหน ทำงานยังไง</h4><p>สำหรับตัว @escaping มองแบบบ้านๆ คือ function ที่เราส่งเป็น parameter สามารถแบ่งได้เป็น 2 อย่างที่จะทำให้เราจำเป็นต้องใส่ @escaping เข้าไป</p><ol><li>function ที่ส่งไปเป็น parameter ถูกเก็บใส่เป็น variable ไว้ (ดู<strong><em>ตัวอย่างที่ 2</em></strong>) จะเห็นว่าเมื่อเราส่ง result parameter เข้าไปใน calculateBMI function ตัว result จะถูกเก็บไว้ใน resultHandler ที่เป็น variable ก่อน แล้วมาเรียกใช้ตอนไหนก็ได้</li><li>ถูกเรียกใน Asynchronous excution ซึ่งอาจจะเป็นใน dispatch queue ก็ได้ (ดู <strong><em>ตัวอย่างที่ 3</em></strong>) จะเห็นว่าตัว resut parameter ถึงแม้จะถูกเรียกใน calculateBMI แต่มันถูกเรียกในอีก 2 วิ ทำให้ตัว result ต้องถูกถือไว้ใน memory ก่อนจนกว่าจะถูกเรียก</li></ol><p><strong><em>ตัวอย่างที่ 2</em></strong></p><pre>var resultHandler: (Float) -&gt; Void = { _ in }</pre><pre>override func viewDidLoad() {</pre><pre>    super.viewDidLoad()</pre><pre>    calculateBMI(height: 1.58, weight: 44.5, result: { bmi in</pre><pre>        print(bmi)</pre><pre>    })</pre><pre>}</pre><pre>func calculateBMI(height: Float,</pre><pre>                  weight: Float,</pre><pre>                  result: @escaping (_ value: Float) -&gt; Void) {</pre><pre>     resultHandler = result</pre><pre>     let bmi = weight/pow(height, 2)</pre><pre>     anotherFunction(bmi: bmi)</pre><pre>}</pre><pre>func anotherFunction(bmi: Float) {</pre><pre>    resultHandler(bmi)</pre><pre>}</pre><p><strong><em>ตัวอย่างที่ 3</em></strong></p><pre>override func viewDidLoad() {</pre><pre>    super.viewDidLoad()</pre><pre>    calculateBMI(height: 1.58, weight: 44.5, result: { bmi in</pre><pre>        print(bmi)<br>    })</pre><pre>}</pre><pre>func calculateBMI(height: Float,</pre><pre>                  weight: Float,</pre><pre>                  result: @escaping (_ value: Float) -&gt; Void) {</pre><pre>     let bmi = weight/pow(height, 2)</pre><pre>     DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {</pre><pre>         result(bmi)<br>     }</pre><pre>}</pre><p>เอาล่ะจาก 3 ตัวอย่างด้านบนขอสรุปอีกครั้งให้เข้าใจมากขึ้นละกันนะ หรืออาจจะงงกว่าเดิม 55555 เอาง่ายๆ ถ้า function ที่ถูกส่งเข้ามาเป็น parameter มีการ keep ค่าไว้ ไม่ว่าจะเป็นด้วย variable หรือการรอ queue เพื่อให้ callback ถูกเรียก เราจำเป็นต้องใส่ @escaping ไว้ที่ parameter ด้วย</p><p>หวังว่าบทความนี้จะมีประโยชน์กับทุกคนที่เข้ามาอ่านจนจบนะ 🙇🏻‍♀️🙇🏻‍♀️🙇🏻‍♀️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=869e948d002c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Action: The feature that make you easily access the important task on iOS13]]></title>
            <link>https://forzfilm.medium.com/quick-action-the-feature-that-make-you-easily-access-the-important-task-on-ios13-355f6159e866?source=rss-39680d8dd79b------2</link>
            <guid isPermaLink="false">https://medium.com/p/355f6159e866</guid>
            <category><![CDATA[ios-13]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[quick-action]]></category>
            <dc:creator><![CDATA[Pattaravadee Luamsomboon]]></dc:creator>
            <pubDate>Sat, 04 Jan 2020 17:09:19 GMT</pubDate>
            <atom:updated>2020-01-04T17:15:06.230Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I will talk about context menus (Simply call it “Quick Action”) which is the new feature on iOS13 and later. If your device supports 3D Touch-enabled, you might familiar with this feature.</p><p><strong>The content in this blog includes</strong></p><ul><li>What is the context menus.</li><li>How are the different between context menus and peek and pop (3D Touch)</li><li>How to implement context menus on UICollectionView, UITableView and UIImage.</li></ul><h3>What is Context menus?</h3><p><strong>Context menus</strong> is similar to Peek and Pop (3D Touch) but it has some difference. The purpose of them is to help facilitate user for accessing important tasks or tasks that are performed frequently.</p><h4><strong>For example</strong></h4><ul><li><strong>On the icon app : </strong>Camera, New post, View Activity and Direct on Instagram. All of these actions is the main feature of application and user often used.</li><li><strong>Within application</strong> : Link preview and action list on Safari.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*uEP5ohQ2Q5Z3yRK_eznGBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*4dU5p3dRZxkFCfIFKafD_w.png" /><figcaption>Finnomena iOS Application contains quick action on the icon app and within application</figcaption></figure><h3><strong>What are the different between Context menus and Peek and Pop?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*9ILszGBFWlrzZLfLz-T9BQ.png" /></figure><p>Do you get bored? Come on wake up. It’s time to code!!!!! 👏🏻👏🏻👏🏻</p><h3>How to implement context menus on UICollectionView, UITableView and UIImage.</h3><p>In this part, I will show my code which implement UICollectionView, UITableView and UIImage with context menu.</p><p><strong>Let’s start with UICollectionView with Context menus part :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/293986ceee6d5a734803f4d09f87d177/href">https://medium.com/media/293986ceee6d5a734803f4d09f87d177/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*kmxtsv-1jsUIiKN7iN0M0w.gif" /></figure><p><strong>UITableView with Context menus part :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f77f8d6964b6929d491b31603edc2b8/href">https://medium.com/media/7f77f8d6964b6929d491b31603edc2b8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*QwgrdWAP98ZGkUjr-sImnw.gif" /></figure><p><strong>UIImage with Context menus part :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d949cce24dd685d3f966e204130315c0/href">https://medium.com/media/d949cce24dd685d3f966e204130315c0/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*2aeglvZANffPnjoy0hmh4g.gif" /></figure><p>Let’s try it yourself!</p><p>I hope this blog will give the benefit for you guys. If you have any question, feel free to ask me. 🤗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=355f6159e866" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>