<?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 Jerski on Medium]]></title>
        <description><![CDATA[Stories by Jerski on Medium]]></description>
        <link>https://medium.com/@jerski71?source=rss-3a95e6430f97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wtzSCMBnpcdSpL9Zm2HJlg.jpeg</url>
            <title>Stories by Jerski on Medium</title>
            <link>https://medium.com/@jerski71?source=rss-3a95e6430f97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 17:30:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jerski71/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[HW#26 Using Code to Make a Card]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-26-using-code-to-make-a-card-6f9be5906cd7?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f9be5906cd7</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Mon, 24 Jan 2022 14:19:20 GMT</pubDate>
            <atom:updated>2022-01-25T03:53:13.424Z</atom:updated>
            <content:encoded><![CDATA[<p>I can’t believe our class ended today. Wow, what a journey! I really learnt a great deal of stuff. This iOS App course truly is amazing and entertaining. No wonder even Bill Gates and Mr. Obama have highly recommended learning how to code. I reckon that living in this high-tech era, we should at least have some fundamental understanding about Apps, coding, and computer science.</p><p>Reflecting back on the preliminary stage in this class, I was anxious and panicked about the course content because I had never learnt anything regarding computer science and coding. I even bought some books to read although they’re not easy.</p><p>Fortunately, our lecturer, Peter, knows how to explain things clearly and patiently. Hence we learnt step by step and improved gradually. When I was an undergraduate, I started to write my own blog, penning down significant or interesting events happened in life. Certainly, it was such a craze that many people wrote blog entries to share their thoughts, highs and lows in life, or complaints. If you didn’t have a blog, you would be regarded as “outdated”, lol. Of course, we know that after Facebook became prevalent, blogs slowly faded away.</p><p>So, it is a bit surprising that I resumed writing blog entries after such a long time; however, this time it is for recording what I’ve learnt in my App class and documenting the steps of assignments. How thrilling it has been; and inconceivably I have written 25 blog entries on Medium so far.</p><p>Today, I am going to demonstrate another simple but quite meaningful assignment. <strong>Using code to make a card</strong>. At the beginning of this course, we learnt how to make a card using Storyboard, which did not require code writing. This time, I would use simple code to do the same sort of homework. Therefore I decided to make a card so I can send it to my good friends in Thailand next year.</p><ol><li><strong>Pick a lotus image</strong>. This flower has significantly important meaning in Thailand because Buddhism is the biggest religion there; and one can see lotus flowers everywhere they go. Lotus flower is considered as a<strong> symbol of purity, enlightenment, self-regeneration and rebirth</strong>. Its characteristics are an excellent analogy for the human condition: even when its roots are in the dirtiest waters, the lotus produces the most stunning flower.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*TctgKrIWz0GsQwL6TTTg2Q.jpeg" /></figure><p>Then, we need to key out the background. If you’re on a Mac, it is relatively easy to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QAX9x_Pt6h796QeksGeNQ.png" /></figure><p>2.<strong> Choose a temple photo</strong>. I took this picture a few years back when I went to Chiang Rai, Thailand. There are loads of temples in Thailand. The dazzling golden colour in the sun is something I’ll never forget. With the freezing and humid weather now, I really miss the sunny and warm Thailand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oaZPnB_1XpMFxYisdRG64A.png" /></figure><p>3. For this assignment, I also checked some seniors’ works. The links are as follows:</p><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E4%BD%9C%E6%A5%AD-12-%E4%BD%BF%E7%94%A8%E5%9C%96%E7%89%87-%E6%96%87%E5%AD%97-emoji-%E9%82%8A%E6%A1%86-%E5%9C%93%E8%A7%92%E8%A3%BD%E4%BD%9C%E6%BC%82%E4%BA%AE%E5%8D%A1%E7%89%87-d3a8eebfc886">作業#12 使用圖片，文字，emoji，邊框 &amp; 圓角製作漂亮卡片</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E4%BD%BF%E7%94%A8%E5%9C%96%E7%89%87-%E6%96%87%E5%AD%97-emoji-%E9%82%8A%E6%A1%86%E5%92%8C%E5%9C%93%E8%A7%92%E8%A3%BD%E4%BD%9C%E6%BC%82%E4%BA%AE%E5%8D%A1%E7%89%87-%E4%B8%8B-3c8ac83cda64">使用圖片、文字、emoji、邊框和圓角製作漂亮卡片(下)</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/8-%E4%BD%BF%E7%94%A8mask-%E9%82%8A%E6%A1%86-%E5%9C%93%E8%A7%92%E8%A3%BD%E4%BD%9C%E6%BC%82%E4%BA%AE%E5%8D%A1%E7%89%87-8c3d4ce35be7">#8 使用mask/邊框 /圓角製作漂亮卡片</a></li></ul><p>More importantly, I practiced using <strong>Mask, Frame</strong>, <strong>CornerRadius, CGAffineTransform </strong>to make the card. Of course, in the code, I got to utilize <strong>for loops </strong>again! It is just much more convenient and save a lot of space. For instance:</p><p><strong>for i in 1..&lt;9 {</strong></p><p><strong>let lilyLeafImageView = UIImageView(image: UIImage(named: “lily-leaf”))</strong></p><p><strong>lilyLeafImageView.frame = CGRect(x: 0, y: i*iconSize, width: iconSize, height: iconSize)</strong></p><p><strong>lilyLeafImageView.transform = CGAffineTransform(rotationAngle: CGFloat.random(in: 0…(.pi*2)))</strong></p><p><strong>cardView.addSubview(lilyLeafImageView)</strong></p><p><strong>}</strong></p><p>I did enjoy making this card for I had to use many things we have learnt throughout this entire course. It’s a bit of recap of many skills. The only thing I had to spend more time was adjusting the frame with the little lotus flowers over the boarders of the card.</p><p>4. Now, let’s take a look at the code I wrote.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BT3GdOPMdXttYeS_DhVyPA.png" /><figcaption>Part I</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S58dfC7JtECHYeoJj8FXHw.png" /><figcaption>Part II</figcaption></figure><p>5. I added <strong>สวัสดีปีใหม่ </strong>on the card. It means Happy New Year in Thai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*1FS7m8Ha7TIf9Qj6OfifLg.png" /></figure><p>6. As for the Chinese character, <strong>蓮</strong>, it means lotus flower.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*PZCAUjFMe0qjPPvMo95Wyg.png" /></figure><p>7. Here is the final result of the card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezLcz0yJT6yLT9qGm0cprw.png" /></figure><p>Last but not the least, many thanks to Peter and a lot of seniors’ fantastic assignments. This App journey that I embarked upon will continue; and I sure hope in the near future, I am able to design some fun Apps. Cheers! Happy Coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f9be5906cd7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-26-using-code-to-make-a-card-6f9be5906cd7">HW#26 Using Code to Make a Card</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#25 Practice of While Loops]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-25-practice-of-while-loops-dfbd58a5e4b7?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfbd58a5e4b7</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Mon, 17 Jan 2022 14:55:36 GMT</pubDate>
            <atom:updated>2022-01-17T15:06:58.083Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve covered the use of Loops and I did <strong>For Loops </strong>in <strong>Playgrounds </strong>the other day. Today, I’m going to practice <strong>While Loops</strong>. It’s also in <strong>Learn to Code 1.</strong></p><p>As it mentions in the introduction, we can <strong>use a while loop to repeat a command or set of commands, while a condition is true.</strong></p><p><strong>While nailIsStickingOut{</strong></p><p><strong>hammerNail()</strong></p><p><strong>}</strong></p><p>It is a relatively simple way to repeat a command.</p><p>1. The first challenge is<strong> Running Code While…</strong></p><p>This one is very simple.</p><p>The code is as follows:</p><p><strong>while isOnClosedSwitch {</strong></p><p><strong>toggleSwitch()</strong></p><p><strong>moveForward()</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qvM51bXiOVANxvlZZOiOA.png" /></figure><p>2. The second challenge is<strong> Creating Smarter While Loops.</strong></p><p>Here we just need to remember ! means not. So while !isBlocked means while it is not blocked. Of course, we need to use if statement to accomplish this task. We will need to write the command: isOnClosedSwitch, toggleSwitch(). Here is the code:</p><p><strong>while !isBlocked {</strong></p><p><strong>if isOnClosedSwitch {</strong></p><p><strong>toggleSwitch ()</strong></p><p><strong>}</strong></p><p><strong>moveForward()</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S9p3s-8rsnXZKgY7oFVoDQ.png" /></figure><p>3. The third challenge is <strong>Choosing the Correct Tool</strong>. This one is to use the best loop to collect all the gems. We need to find the pattern first. As we can see from the game, in order to collect a gem, we have to do the following movements.</p><p><strong>moveForward()turnLeft()collectGem()turnRight()</strong></p><p>So, we will write a function of the above movements, which <strong>is func turnAndCollectGem()</strong>. Then we use while loop to repeat the command.</p><p>The code is as follows:</p><p><strong>func turnAndCollectGem() {</strong></p><p><strong>moveForward()</strong></p><p><strong>turnLeft()</strong></p><p><strong>moveForward()</strong></p><p><strong>collectGem()</strong></p><p><strong>turnRight()</strong></p><p><strong>}</strong></p><p><strong>while !isBlocked{</strong></p><p><strong>turnAndCollectGem()</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b_GNTUzrxLJPuPzm4YdPDw.png" /></figure><p>4. The fourth challenge is <strong>Four by Four</strong>. This task is to choose the best loops and toggle the switches. Again, we just need to calculate the movements we need to finish the work. We will use both <strong>while loop and if statement.</strong> The code is:</p><p><strong>while !isBlocked{</strong></p><p><strong>moveForward()</strong></p><p><strong>moveForward()</strong></p><p><strong>moveForward()</strong></p><p><strong>turnRight()</strong></p><p><strong>if isOnClosedSwitch{</strong></p><p><strong>toggleSwitch()</strong></p><p><strong>}</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtF5f-h_yX2r5JYenYotkg.png" /></figure><p>5. The fifth challenge is <strong>Turned Around.</strong> Here we are to choose the tools that will help us find the most efficient solutions. After studying the game, we need to collect the gems and in order to do that, we have to basically move, collect gem, and turn. So, we can first declare a function: <strong>func moveCollectTurn()</strong>, which includes the movements:<strong> moveForward(), collectGem(), turnLeft()</strong></p><p>Then, we will use for loops to repeat the above commands in the func.</p><p>The code is as follows:</p><p><strong>func moveCollectTurn(){</strong></p><p><strong>moveForward()</strong></p><p><strong>collectGem()</strong></p><p><strong>turnLeft()</strong></p><p><strong>}</strong></p><p><strong>for i in 1 … 4 {</strong></p><p><strong>moveCollectTurn()</strong></p><p><strong>moveCollectTurn()</strong></p><p><strong>moveForward()</strong></p><p><strong>turnRight()</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFSgQ4tUJ5TTr2zw31UyGQ.png" /></figure><p>6. The sixth challenge is <strong>Land of Bounty.</strong> This is to find an efficient solution that works the best. In fact, there are many different approaches. The most important part is how to declare the function that helps us to toggle switches and collect gem. This one took me a little longer than I thought, but it was fun! Here I wrote my code as follows:</p><p><strong>func checkSwithGem(){</strong></p><p><strong>if isOnClosedSwitch{</strong></p><p><strong>toggleSwitch()</strong></p><p><strong>} else if isOnGem {</strong></p><p><strong>collectGem()</strong></p><p><strong>}</strong></p><p><strong>}</strong></p><p><strong>func solveLine() {</strong></p><p><strong>moveForward()</strong></p><p><strong>while !isBlocked {</strong></p><p><strong>checkSwithGem()</strong></p><p><strong>moveForward()</strong></p><p><strong>}</strong></p><p><strong>}</strong></p><p><strong>solveLine()</strong></p><p><strong>turnRight()</strong></p><p><strong>moveForward()</strong></p><p><strong>turnRight()</strong></p><p><strong>solveLine()</strong></p><p><strong>turnLeft()</strong></p><p><strong>moveForward()</strong></p><p><strong>turnLeft()</strong></p><p><strong>solveLine()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DxPRzSHR0A8FywTB7n4CrQ.png" /></figure><p>7. The seventh challenge is <strong>Nesting Loops.</strong> This one is what we spent most of time learning in tonight’s class. It’s a bit complicated but not that hard if you observe carefully. Basically, in this task, the nesting loops are to let us use a loop inside another loop to move around a spiral.</p><p>The code is as follows:</p><p><strong>while !isBlocked {</strong></p><p><strong>while !isOnGem{</strong></p><p><strong>moveForward()</strong></p><p><strong>}</strong></p><p><strong>collectGem()</strong></p><p><strong>turnLeft()</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k1ccf6rFPsAf4GfVMqrlWQ.png" /></figure><p>8. The eighth challenge is<strong> Random Rectangles.</strong> This task is to use nested loops and conditions to move around a changing world. After having finished the Nesting Loops practice, this one is not hard at all. Here is the code:</p><p><strong>while !isBlocked {</strong></p><p><strong>while !isBlocked {</strong></p><p><strong>moveForward()</strong></p><p><strong>}</strong></p><p><strong>turnRight()</strong></p><p><strong>}</strong></p><p><strong>toggleSwitch()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuxsULiVZM5vKZmluVxY7g.png" /></figure><p>9. The last one is <strong>You’re Always Right.</strong> This one is to let us apply what we’ve done in this practice to write any coding or pattern we like as long as we can accomplish the task. While I was tackling this task, it reminded me of the video game “Monument Valley”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*plA2LtR6yApn_CId3pmFDg.png" /><figcaption>I love this game!</figcaption></figure><p>If you have played this wonderful game (the music is fantastic), I think it’ll be very easy to reinforce the concept of <strong>While Loops</strong> here. The code is as follows:</p><p><strong>while !isBlocked {</strong></p><p><strong>while !isBlocked {</strong></p><p><strong>moveForward()</strong></p><p><strong>if isOnClosedSwitch {</strong></p><p><strong>toggleSwitch()</strong></p><p><strong>}</strong></p><p><strong>}</strong></p><p><strong>turnRight()</strong></p><p><strong>if isOnGem {</strong></p><p><strong>collectGem()</strong></p><p><strong>}</strong></p><p><strong>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-c8kB9rTRuxdvWB3-RZNQA.png" /></figure><p>Well, this is the power of <strong>While Loops</strong>! I reckon it is really fun. Until next time, cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfbd58a5e4b7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-25-practice-of-while-loops-dfbd58a5e4b7">HW#25 Practice of While Loops</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#24 Practice of “For Loops”]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-24-practice-of-for-loops-db1cbef63a56?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/db1cbef63a56</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Thu, 13 Jan 2022 10:40:56 GMT</pubDate>
            <atom:updated>2022-01-13T14:59:33.120Z</atom:updated>
            <content:encoded><![CDATA[<p>After having done quite a lot in Storyboard, I decided to do some more practice in Swift Playgrounds. Today I chose “For Loops” to do some coding.</p><p>As it mentions in the introduction, to break down coding tasks, we write functions for repeated patterns. Now, we’ll call one function multiple times using a <strong>loop</strong>. <strong>With a loop, we write our code just once and enter the number of times to repeat it</strong>. I’m sure many of us have done that already for other Storyboard assignments.</p><p>1. The firs challenge is <strong>Using loops</strong>. This one is easy. The code I wrote is as follows:</p><p><strong>for</strong> i <strong>in</strong> 1 …5 {</p><p>moveForward()</p><p>moveForward()</p><p>collectGem()</p><p>moveForward()</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dfjdUl_8udlO-dQrJ1f6vw.png" /></figure><p>2. The second challenge is<strong> Looping All the Sides.</strong></p><p>Again, this one is simple. The code is as follows:</p><p><strong>for</strong> i <strong>in</strong> in …4 {</p><p>moveForward()</p><p>collectGem()</p><p>moveForward()</p><p>moveForward()</p><p>moveForward()</p><p>turnRight()</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4SRYYQezELoFkcl4A6EKg.png" /></figure><p>3. The third challenge is <strong>To the Edge and Back.</strong></p><p>This one starts to get a bit challenging. One thing we need to notice is that a func <strong>turnaround() </strong>has to be declared and in the function there are two times of turnLeft(). Another func is func <strong>moveTwoToggleAndReturn()</strong> we can declare to include the necessary movements, including <strong>toggling switches</strong>.</p><p>Then, we add the loop at the end.</p><p>Here is the code I wrote:</p><p><strong>func</strong> turnAround(){</p><p>turnLeft()</p><p>turnLeft()</p><p>}</p><p><strong>func</strong> moveTwoToggleAndReturn(){</p><p>moveForward()</p><p>moveForward()</p><p>toggleSwitch()</p><p>turnAround()</p><p>moveForward()</p><p>moveForward()</p><p>turnAround()</p><p>}</p><p><strong>for</strong> i <strong>in</strong> 1…4{</p><p>moveTwoToggleAndReturn()</p><p>turnRight()</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60HNl3zFsW9-zVu0h2BOrw.png" /></figure><p>4. The fourth challenge is <strong>Loop Jumper.</strong> This one is not hard at all.</p><p>The code is as follows:</p><p><strong>for</strong> i <strong>in</strong> 1…5{</p><p>moveForward()</p><p>turnLeft()</p><p>moveForward()</p><p>moveForward()</p><p>collectGem()</p><p>turnRight()</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xZtGOnp42s_x_OuPsDQ7g.png" /></figure><p>As we can see from this code, how powerful a loop is. It saves us a lot of time!</p><p>5. The fifth challenge is <strong>Branch Out.</strong> This one isn’t that difficult either. What we need to do first is to closely see what action we must take to achieve the goal. Then, we can decide what to put in our code. Again, at the beginning, we need to declare a func —<strong>func turnaround()</strong>, which includes the action <strong>turnLeft()</strong> twice.</p><p>Then, we declare another func — <strong>funchandleBigStairs(),</strong> which includes the loop for moving forward seven times. Then, we add t<strong>oggleSwitch()</strong> and <strong>turnaround()</strong>; and put another loop for moving forward 7 times. After that, we make a move,<strong> turnRight()</strong>. Last, we add a loop for 3 times, which includes <strong>moveForward() twice, turnRight() once and handleBigstairs()</strong>.</p><p>The code is as follow:</p><p><strong>func</strong> turnAround(){</p><p>turnLeft()</p><p>turnLeft()</p><p>}</p><p><strong>func</strong> handleBigStairs(){</p><p><strong>for</strong> i <strong>in</strong> 1 … 7 {</p><p>moveForward()</p><p>}</p><p>toggleSwitch()</p><p>turnAround()</p><p><strong>for</strong> i <strong>in</strong> 1 … 7 {</p><p>moveForward()</p><p>}</p><p>turnRight()</p><p>}</p><p><strong>for</strong> i <strong>in</strong> 1 … 3 {</p><p>moveForward()</p><p>moveForward()</p><p>turnRight()</p><p>handleBigStairs()</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qf4Wp8VIf8g0HgdnDkGpaQ.png" /></figure><p>6. The sixth challenge is <strong>Gem Farm</strong>. This one is to decompose multiple patterns into functions and loops. It gets a bit daunting but I managed to do it. Here is the code:</p><p><strong>func</strong> turnAround(){</p><p>turnRight()</p><p>turnRight()</p><p>}</p><p><strong>func</strong> toggleTwoSwitches(){</p><p><strong>for</strong> i <strong>in</strong> 1 … 2 {</p><p>moveForward()</p><p>toggleSwitch()</p><p>}</p><p>turnAround()</p><p><strong>for</strong> i <strong>in</strong> 1 … 2 {</p><p>moveForward()</p><p>}</p><p>}</p><p><strong>func</strong> collectTwoGems(){</p><p><strong>for</strong> i <strong>in</strong> 1 … 2 {</p><p>moveForward()</p><p>collectGem()</p><p>}</p><p>turnAround()</p><p><strong>for</strong> i <strong>in</strong> 1 … 2 {</p><p>moveForward()</p><p>}</p><p>}</p><p><strong>func</strong> cleanOneRowOfSwitchesAndGems(){</p><p>toggleTwoSwitches()</p><p>collectTwoGems()</p><p>}</p><p><strong>for</strong> i <strong>in</strong> 1 … 2 {</p><p>turnLeft()</p><p>cleanOneRowOfSwitchesAndGems()</p><p>turnRight()</p><p>moveForward()</p><p>}</p><p>turnLeft()</p><p>cleanOneRowOfSwitchesAndGems()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rUIXRKfBq0MjpT2TU5D4ig.png" /></figure><p>As we can see now, we have to use a lot of loops in this challenge. It’s not easy but fun!</p><p>7. The seventh challenge is <strong>Four Stash Sweep</strong>. This is to practice pattern finding, decomposition, functions, and for loops.</p><p>Again, we must study what kind of action we need and how to execute it. This task consists of what we have done previously and it’s a good review and practice. Here is the code:</p><p><strong>func</strong> takeRightCorner() {</p><p>moveForward()</p><p>turnRight()</p><p>moveForward()</p><p>turnAround()</p><p>}</p><p><strong>func</strong> turnAround(){</p><p>turnRight()</p><p>turnRight()</p><p>}</p><p><strong>func</strong> moveAndCollectThree() {</p><p><strong>for</strong> i <strong>in</strong> 1 … 3 {</p><p>collectGem()</p><p>moveForward()</p><p>}</p><p>}</p><p><strong>func</strong> handleCluster(){</p><p>moveForward()</p><p>moveForward()</p><p>collectGem()</p><p>turnAround()</p><p>takeRightCorner()</p><p>moveAndCollectThree()</p><p>}</p><p><strong>for</strong> i <strong>in</strong> 1 … 4 {</p><p>handleCluster()</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NoIDcvZVp56z35GdGuFUeA.png" /></figure><p>Well, one thing I learnt is that it is very critical to declare a function using <strong>func.</strong> And we can create our own type names for the func. One thing we have done a lot in our Storyboard assignments. Cool, right?</p><p>That’s it for this practice. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db1cbef63a56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-24-practice-of-for-loops-db1cbef63a56">HW#24 Practice of “For Loops”</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#23 Multiple Choice App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-23-multiple-choice-app-12af890f095a?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/12af890f095a</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 21:40:56 GMT</pubDate>
            <atom:updated>2022-01-11T06:00:10.066Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>More practice of</strong> <strong>Variables, If Else, Array, Class, Random, IBOutlet &amp; IBAction</strong></p><p>This is an interesting assignment; and we went through quite a lot of details. The most important thing I learnt is how to build a question base via <strong>Airtable and then parse csv and change it into array. Here is the link below:</strong></p><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E5%88%A9%E7%94%A8-codablecsv-%E8%A7%A3%E6%9E%90-csv-%E4%BB%A5airtable-%E7%82%BA%E4%BE%8B-1cc8bc6a9570">利用 CodableCSV 解析 csv，以Airtable 為例</a></p><p>Then in the project, we can use <strong>SPM to add CodableCSV</strong>. The link is as follows:</p><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E4%BD%BF%E7%94%A8-spm-%E5%AE%89%E8%A3%9D%E7%AC%AC%E4%B8%89%E6%96%B9%E5%A5%97%E4%BB%B6-xcode-11-%E6%96%B0%E5%8A%9F%E8%83%BD-2c4ffcf85b4b">使用 SPM 安裝第三方套件 — 以抓圖套件 Kingfisher 為例</a></p><p>I also practiced how to add Kingfisher into my project.</p><p>Today I decided to make <strong>British English Game</strong>. As we know, there are some varieties of English across the globe. Most time, we are only aware of American English in Taiwan. In fact, people speak British, Australian or even Singaporean English in many parts of this world. Luckily, I took a course about varieties of English in university in the UK. Hence I had learnt some British English.</p><p>And certainly, I have checked some of the seniors’ works so as to get more understanding. Some great examples are here:</p><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/25-%E5%8F%A2%E6%9E%97%E5%86%92%E9%9A%AA-%E9%81%B8%E6%93%87%E9%A1%8C-app-6582a255a703">#43 叢林冒險 選擇題 App</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/20-%E5%9F%BA%E6%9C%ACswift%E9%81%B8%E6%93%87%E9%A1%8Capp-2c4bc542b286">#20 基本Swift選擇題App</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/q-a%E9%81%B8%E6%93%87%E9%A1%8C-%E8%AA%8D%E8%AD%98%E5%8B%95%E7%89%A9-e18d453122ac">Q&amp;A選擇題｜認識動物</a></li></ul><p>Let’s take a look at the code I wrote:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7687ceeadda679cfb1edc30577fbb0a/href">https://medium.com/media/e7687ceeadda679cfb1edc30577fbb0a/href</a></iframe><p>And the interface of the App:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MDCdAXltXlzSawocsvqduA.png" /></figure><p>Well, I won’t go into detail about how the layout was built in <strong>Storyboard</strong> as we’ve done many times and are supposed to be very familiar with all those <strong>UI elements</strong> such as<strong> label , image view, &amp; button.</strong></p><p>One thing I do want to mention is that we need to declare variables in<strong> class </strong>such as</p><p><strong>var questions = Question.data</strong></p><p><strong>var index = 0</strong></p><p><strong>var score = 0</strong></p><p>otherwise, you might find errors like “cannot find score in scope”. This game is simple. There are 10 questions. Each question contains four choices and only one is correct. And if you get one correct answer, you gain 10 points. The score shows on the upper right corner.</p><p>There are still quite a lot of things I have to review and practice, but I really appreciated what our lecturer has taught us.</p><p>One other critical thing is how to write the code about the questions I created as a data base into the <strong>new swift file</strong> in my project. Again, here we<strong> import CodableCSV</strong> in order to faciliate the procedure of using loads of questions in my App.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5ad239878949d77429b579e318ea73c/href">https://medium.com/media/d5ad239878949d77429b579e318ea73c/href</a></iframe><p>Lastly, let’s see the gif of this App. I hope you can answer some questions correctly. They’re not that hard, are they? lol</p><p>Until next time, cheers! Happy Coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*3gUYFyuJbKCBm-gq2HDZbQ.gif" /></figure><p><strong>GitHub:</strong></p><p><a href="https://github.com/JerskiHuang/BritishEnglishGameNew">GitHub - JerskiHuang/BritishEnglishGameNew</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12af890f095a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-23-multiple-choice-app-12af890f095a">HW#23 Multiple Choice App</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#22 College Cost Calculation App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-22-college-cost-calculation-app-c3edcb7af0dc?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3edcb7af0dc</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Sun, 09 Jan 2022 10:37:14 GMT</pubDate>
            <atom:updated>2022-01-10T06:18:52.699Z</atom:updated>
            <content:encoded><![CDATA[<p>More practice of IBAction, IBOutlet, Optional, &amp; Keypad</p><p>Although the arithmetics in this App is relatively simple, it is fun going through what we have covered in class. In this homework, I chose to make a college cost calculation app.</p><p>Yep, it is getting more and more costly studying abroad, especially if one wants to enter those prestigious and top-notch universities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*9sZ9woW5BjOAaCdhK4mhAg.png" /></figure><p>Here are the links I have checked in order to make this app:</p><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/35-%E8%B2%93%E9%A0%AD%E9%B7%B9%E5%B0%8F%E8%B2%BB%E8%A8%88%E7%AE%97%E6%A9%9Fapp-2f0a35903df0">#38 貓頭鷹小費計算機APP</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/35-%E6%8F%9B%E7%AE%97-app-%E5%B0%8F%E8%B2%BB%E5%88%86%E6%94%A4app-87ed7b5efb14">#35 換算 App：小費分攤App</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/%E5%B0%8F%E8%B2%BB-app-%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-ios-app-%E4%BD%9C%E6%A5%AD-89c3a831f82c">#35 換算 App，比方小費，BMI，BMR，匯率，單位換算</a></li></ul><p>Let’s take a look at the code I wrote:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a98e05f817a8878093cbd68ac341d64c/href">https://medium.com/media/a98e05f817a8878093cbd68ac341d64c/href</a></iframe><p>My calculation is simple, just add all the items of cost to get the total cost for studying at a university for one year. Then divide the total cost with 12 to get the cost per month.</p><p>Notice that : I wrote <strong>“%.1f”</strong> to calculate the number to the first decimal place.</p><p>// calculate the total cost</p><p><strong>let totalCost = tuition + livingCost + insurance + housing + books totalCostLabel.text = String(format: “%.1f”, totalCost) + “ USD”</strong></p><p><strong>// calculate per month cost let perMonthCost = totalCost / 12 perMonthCostLabel.text = String(format: “%.1f”, perMonthCost) + “ USD”</strong></p><p>Let’s take a look at the interface of the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pt21OGEdpwmQq68GPuUeIw.png" /></figure><p>Because I wanted to practice using SpriteKit again, so I added the snow particle effect. This time I changed the symbol to the money sign. At the beginning I forgot to add “Import SpriteKit” in the code, so the effect couldn’t come out. Luckily, I found that out right away.</p><p>Another issue I figured out how to solve is that if you cannot see the keypad jump out, you can go to Simulator →I/0 →Keyboard → click Connect Hardware Keyboard. Then the keypad should appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MK3PDUm6Wr3Rgfqh9yyLWQ.png" /></figure><p>Finally, here is the gif of the app. Happy Coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6Hy8ubBJTO2Iuag057iUYw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3edcb7af0dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-22-college-cost-calculation-app-c3edcb7af0dc">HW#22 College Cost Calculation App</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#21 More Practice of IBOutlet, IBAction &If Else]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-21-more-practice-of-iboutlet-ibaction-if-else-bdcf18720031?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdcf18720031</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Mon, 03 Jan 2022 20:53:47 GMT</pubDate>
            <atom:updated>2022-01-04T03:53:35.932Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Ordering Delicious Hot Pot</strong></p><p>Tonight, we’ve covered some new things, especially the use of<strong> if &amp; else</strong> in coding. Of course we also practiced <strong>IBOutlet and IBAction</strong>. This time I chose to do more about different <strong>UI elements</strong> such as <strong>Label, Stepper, Slider, Button,</strong> <strong>Switch, TextField</strong>, etc because it is very critical to practice more otherwise, one can easily forget how to use them in designing an App.</p><p>With this homework, I also checked some of the seniors’ and Peter’s works as follows:</p><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/%E6%93%87%E5%81%B6%E6%A2%9D%E4%BB%B6-app-%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-ios-app-%E4%BD%9C%E6%A5%AD-45823196267d">#2 輸入條件顯示結果，比方擇偶條件，訂飲料，找主人 App</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/2-%E6%93%87%E5%81%B6%E6%A2%9D%E4%BB%B6app-%E8%A8%82%E9%A3%B2%E6%96%99-27461adcc997">#2 擇偶條件App — 訂飲料</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/2-%E6%93%87%E5%81%B6%E6%A2%9D%E4%BB%B6app-%E9%81%B8%E5%80%8B%E8%9B%8B%E7%B3%95%E5%90%A7-df1a705c7944">#2 擇偶條件App — 選個蛋糕吧</a></li></ul><p>As for the topic, I decided to make an App which allows people to order Hot Pot! Yes, hot pot is very popular all year round in Taiwan. People can put anything they like to eat in a pot that continues to boil. There are various kinds of broth such as spicy soup, kimchi, veggie, and milk. Here is a photo of hot pot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*6r5GT6IZowABphLQt_KIjg.jpeg" /><figcaption>Yummy!</figcaption></figure><p>Now, let’s take a look at the code. It is relatively easy as we have done quite a lot for the last few assignments. SO, I will not go into detail. Just remember that you need to set the value for the<strong> slider and stepper</strong>. I do appreciate what the seniors’ works showed me, which saved me a lot of time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42d4f58c3589bcd8d157e475d3e73c13/href">https://medium.com/media/42d4f58c3589bcd8d157e475d3e73c13/href</a></iframe><p>Finally, let’s take a look at the App’s interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tCKAjGXEGeXbZ9Avz9h3A.png" /></figure><p>And, see the gif of this App. I too attached the Github link below. Cheers!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*PfwAQHTmgOcYnEaMEI4JjA.gif" /></figure><p><a href="https://github.com/JerskiHuang/HotPot1">GitHub - JerskiHuang/HotPot1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdcf18720031" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-21-more-practice-of-iboutlet-ibaction-if-else-bdcf18720031">HW#21 More Practice of IBOutlet, IBAction &amp;If Else</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW# 20 Imitating Google Search: A Small Game App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-20-imitating-google-search-a-small-game-app-433df3310050?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/433df3310050</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Thu, 30 Dec 2021 02:19:06 GMT</pubDate>
            <atom:updated>2021-12-30T10:38:19.307Z</atom:updated>
            <content:encoded><![CDATA[<p>Finally, I’ve come to homework #20! I can’t believe how time flies. We’ve covered a lot of stuff already and there are still many things I need to review and practice, otherwise I’ll get rusty soon. lol…</p><p>Anyway, after checking the relevant links below, I decided to do an app for the <strong>cast moon blocks </strong>or <strong>cast divination blocks</strong>, a very important custom in Taiwanese religious practice.</p><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/113-%E6%A8%A1%E4%BB%BF-google-search-%E5%B0%8F%E9%81%8A%E6%88%B2%E8%A3%BD%E4%BD%9C-ios-app-9fa3456bcb1f">#113 模仿 Google search 小遊戲製作 iOS App</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/swift-practice-60-wrok-113-%E7%8E%A9%E9%81%8A%E6%88%B2-%E4%BB%BF%E9%80%A0google%E7%9A%84%E5%B0%8F%E9%81%8A%E6%88%B2-fb8c9773b085">Swift Practice#60 &amp; Wrok#113 玩遊戲！仿造Google的小遊戲。</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/work-7-4-%E6%A8%A1%E4%BB%BF-google-search-%E5%B0%8F%E9%81%8A%E6%88%B2%E8%A3%BD%E4%BD%9C-ios-app-ef7265ee3d15">Work(7–4)模仿 Google search 小遊戲製作 iOS App</a></li></ul><p>In Taiwanese, we call <strong>cast divination blocks <em>“ poa̍h-poe”</em></strong>. When we pray to Gods or our ancestors, we sometimes ask them questions, then cast the divination blocks on the ground; and the answers with the divination blocks come into three kinds: good, bad, no answer (smile). See the following pictures:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*KuTShXtsmOU4aWDsaJyjcQ.png" /><figcaption>This means it’s good.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*14yrNWL4L_EnL3-H8stMJg.png" /><figcaption>This means it’s bad.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*bu-STsxfBnWk5Zp4H3VcBw.png" /><figcaption>This means no answer or keep trying</figcaption></figure><p>For this game, I tried to integrate some of the stuff we did before, like <strong>SpriteKit </strong>with the <strong>snow particle effect.</strong></p><p>Here is my simple code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8TJjAKb17cWTk0XcGaYDw.png" /><figcaption>Part 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XG28qrndboLM0MJpwamExg.png" /><figcaption>Part 2</figcaption></figure><p>I was a bit stuck during the coding process but luckily I figured out the problem. It just needs a lot of patience when writing code, eh? Regarding the random cast connecting to the results of <strong>good, bad, and smile</strong>, I THIK I could do better some time later, like making the result words disappear when there is no cast being picked up randomly. This game, however, is just for fun. <strong>When casting your divination blocks, you should get the ‘good’ one to match the result word- good, which means you win; otherwise, you need to keep casting the blocks.</strong></p><p>Alrighty, let’s take a look at the interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQ5Y-YOwbAb0hcpjBV13yg.png" /><figcaption>Tap CAST button to get your fortune!</figcaption></figure><p>Last, let’s see the gif of the app. I know it is not that great and I can’t compete with those who are designers. But hey, I think I’m getting more progress as the class is coming toward the end. I really appreciated many seniors’ works and of course our lecturer, Peter.</p><p>The link on Github:</p><p><a href="https://github.com/JerskiHuang/DivinationGame">GitHub - JerskiHuang/DivinationGame</a></p><p>Until next time, Happy New Year of 2022!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*CrvBaDwFDf1bAJrzFxlIew.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=433df3310050" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-20-imitating-google-search-a-small-game-app-433df3310050">HW# 20 Imitating Google Search: A Small Game App</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#19 More Practice of Outlet, Action, UIColor, UISlider &Random Function]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-19-more-practice-of-outlet-action-uicolor-uislider-random-function-a2eb051524c2?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2eb051524c2</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Mon, 27 Dec 2021 19:27:51 GMT</pubDate>
            <atom:updated>2021-12-28T08:38:54.461Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we have reviewed what we did last week about <strong>outlet, action, UIColor, and UISlider.</strong> And we also tried to add <strong>random</strong> function. It’s really cool to practice more about these elements and functions, especially through coding.</p><p>I chose one of the popular iconic dieties in Daoism in Taiwan-<strong>Sam-Tai-Zu (The Third Prince)</strong>.</p><p><strong>Image source:</strong> https://www.supayro.com.tw/q版%EF%BC%8E節慶/三太子/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*tkHfjnrjwi3dDiCT3TYmyw.jpeg" /></figure><p>Here is the code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKvbp5CkmcROhkPvYyJ7Og.png" /></figure><p>One thing I got stuck during the coding process was missing the action that should be connected to the designated target. Luckily Peter reminded me one of the articles that he talked about in class, which helped me to solve the problem. Please see the link below:</p><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/outlet-%E6%88%96-action-%E6%89%BE%E4%B8%8D%E5%88%B0%E9%80%A3%E7%B7%9A%E7%9B%AE%E6%A8%99-%E9%80%A0%E6%88%90-app-%E9%96%83%E9%80%80-7056edbc9ff3">outlet 或 action 找不到連線目標，造成 App 閃退</a></p><p>Now, let’s take a look at some of the colors I changed for The Third Prince’s face.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rcpUN6qcO9M5kRxlqkqbYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPmXxpbcVSIgdcBj5D6uKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Pq-1N_ae1jLXhnlcgkK2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeTa_lLBntxUCQppn9a4Gg.png" /></figure><p>And lastly, let’s see the gif of the sliders and random connected together to make the face’s color change. I know I can make some more design about the View but I’m really not that artistic. However, I enjoyed this homework or I should say I have enjoyed all the practice work we needed to do…Cheers!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*KxRSbmo61qRtw2yQvp4uEg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2eb051524c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-19-more-practice-of-outlet-action-uicolor-uislider-random-function-a2eb051524c2">HW#19 More Practice of Outlet, Action, UIColor, UISlider &amp;Random Function</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#18 Practice of Code Writing]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-18-practice-of-code-writing-78fb21c9df37?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/78fb21c9df37</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Sat, 25 Dec 2021 03:44:09 GMT</pubDate>
            <atom:updated>2021-12-26T06:46:14.034Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Getting more familiar with Variables via Playgrounds App</strong></p><p>A while ago, Peter has mentioned <strong>Playgrounds </strong>and encouraged us to practice coding via games. Today, I’m going to show some interesting parts in <strong>Learn to Code 2 </strong>with this cute little alien-like creature collecting gems or toggling switches.</p><p>For someone like me who doesn’t really play video games a lot, this is relatively fun and refreshing to practice writing code.</p><p><strong>First</strong>, go to Playgrounds App and click <strong>Learn to Code 2</strong>. Here mine is written in Mandarin before I switched the language to English.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwRE4llWAawZSSQ_ZzQy0w.png" /></figure><p><strong>Second</strong>, on the left sidebar, you will see the contents of Chapters. The first one is Variables. Read the brief <strong>Introduction </strong>to get some basic ideas of Variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXu9bNG_WQ_G2W1uVUyEfA.png" /></figure><p><strong>Third</strong>, start with the first challenge <strong>Keeping Track! </strong>This one is quite easy if you rememer what we have learnt about <strong>var </strong>in class.<strong> I used moveForward() to make the creature move one step and since we have declared var gemCounter = 0, then we could write gemCounter = 1 at the end.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXwpNhPxohdjf6oHYZ07pw.png" /></figure><p><strong>Fourth</strong>, the second challenge<strong> Bump Up the Value.</strong> The challenge is to assign a new value to gemCounter to each additional gem collected. Again, we set <strong>var gemCounter = 0 </strong>to begin with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N8Lxl3l8SkX3OTxT8eQV3A.png" /></figure><p><strong>Fifth</strong>, the third challenge is <strong>Incrementing the Value</strong>. The goal here is to <strong>increment your variable to track the number of gems collected.</strong> Here I learnt how to use<strong> if, while and !(means not). </strong>I actually had to search some info on the Internet to get better understanding. Although it took me some time, it was worth it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QR3pfSFq630jBg7KevKWEQ.png" /></figure><p><strong>Sixth</strong>, the fourth challenge is <strong>Seeking Seven Gems</strong>. The goal is to <strong>find exactly seven gems</strong>. Here we need to use a comparison operator :</p><p><strong>while gemCounter &lt; 7 { }</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dN0ETSQ5o12BTbL3b1bRQQ.png" /></figure><p><strong>Seventh</strong>, the fifth challenge is<strong> Three Gems, Four Switches.</strong> The goal is to <strong>collect exactly three gems and toggle open four switches</strong>. To begin with we need to have two separate variables; one is for <strong>the number of gems</strong>, the other is for <strong>the number of switches</strong>. We also need to use more comparison operators here. Luckily in the introduction, it is clearly explain what we have to do and the meaning of <strong>“less than operator (a &lt;b) returns true if a is less than b.” Here it reminds us that equal to operator is written like (a ==b) &amp; not equal to is (a !=b).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnQ_Pt-voxC3XFe4LeqZgQ.png" /></figure><p><strong>Eighth,</strong> the sixth challenge is <strong>Checking for Equal Values.</strong> The goal is <strong>to collect as many gems as there are switches.</strong> Here we’ll use <strong>a constant called switchCounter (</strong>declare with<strong> let) . In this challenge, we again will use some comparison operators.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fpGjOq09eHKsAxnupkYAw.png" /></figure><p><strong>Ninth,</strong> the seventh challenge is<strong> Round up the Switches. </strong>The goal is to<strong> toggle the same number of switches as gems collected. </strong>Here we use<strong> compound assignment operator to add a value to a variable and assign the new value at the same time. One thing we can do is shorten the assignment:</strong></p><p><strong>gemCounter = gemCounter +1 — — &gt;gemCounter += 1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7F68XH8BKStMZ56bZ_1ZA.png" /></figure><p><strong>Last</strong>, the eighth challenge is <strong>Collect the Total.</strong> The goal is to <strong>collect a randomly determined number of gems, represented by totalGems.</strong></p><p>Here we use a constant <strong>totalGems:</strong></p><p><strong>let totalGems = randomNumberOfGems</strong></p><p>This challenge took me some time as I tried to find out how to make the creature turn around when there is no way in front of it. I then figured out writing <strong>turnLeft() twice</strong>. It is a good review of what we have done previously.</p><p>I did enjoy this practice and for those who want to get more familiar with coding, this game-oriented playgrounds is definitely a top pick! Until next time, cheers!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7n3AbhWLQA8gk8eAbW2gw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78fb21c9df37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-18-practice-of-code-writing-78fb21c9df37">HW#18 Practice of Code Writing</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HW#17 Practice using page control，segmented control & button etc. to change contents]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/hw-17-practice-using-page-control-segmented-control-button-etc-to-change-contents-b75eb5916c3a?source=rss-3a95e6430f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/b75eb5916c3a</guid>
            <dc:creator><![CDATA[Jerski]]></dc:creator>
            <pubDate>Mon, 20 Dec 2021 16:53:58 GMT</pubDate>
            <atom:updated>2021-12-21T05:46:15.566Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Goal: Using connecting elements to make images change</strong></p><p>Tonight we have covered how to connect elements using<strong> IBAction &amp; IBOutle</strong>t. This is is really cool because we could directly write code to add actions to the UI elements. Unlike what we did in Storyboard, just dragging the desired UI elements onto the interface builder, this class taught us how to write specific code to do the same functions.</p><p>In fact, I have tried to read other people’s works and got a bit of understanding. However, after Peter’s class, it became much clearer about the entire process. Here are some links I have come across as references:</p><ul><li><a href="https://developer.apple.com/documentation/uikit/uisegmentedcontrol/1618575-selectedsegmentindex">selectedSegmentIndex | Apple Developer Documentation</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E9%81%8B%E7%94%A8-page-control-segmented-control-button-gesture-%E6%84%9B%E5%9C%A8%E4%B8%89%E9%83%A8%E6%9B%B2-c285cd4f1523">運用 page control、segmented control、button &amp; gesture — 愛在三部曲</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E4%B8%80%E7%AE%AD%E7%A9%BF%E5%BF%83-10%E5%8F%A5%E8%A9%B1-%E8%AA%AA%E9%80%B2%E6%B0%B4%E7%93%B6%E5%BA%A7%E7%9A%84%E5%BF%83%E5%9D%8E%E8%A3%A1-%E6%93%9A%E8%AA%AA%E6%B0%B4%E7%93%B6%E5%80%91%E7%9C%8B%E5%AE%8C%E9%83%BD%E5%93%AD%E4%BA%86-10yearchallenge-%E6%99%82%E9%96%93%E9%83%BD%E5%8E%BB%E5%93%AA%E4%BA%86-ec28abc189bd">一箭穿心！「10句話」說進水瓶座的心坎裡！據說水瓶們看完都哭了！（10YearChallenge，時間都去哪了）</a></li></ul><p>With some thought, I decided to select <strong>Salt Lake City</strong> as my topic as I had fond memories over there when I studied at University of Utah. Salt Lake City is a very beautiful city with loads of Mormon influences. As their pioneers moved from the east to the west, they settled down in Utah and spent years building up this city. It’s not easy to search suitable photos on the Internet but I found some nice ones via the websits such as <strong>Pinterest &amp; Flickr.</strong> I chose the years, 1900, 1920, 1940, 1960, 1980, 1990, 2000, &amp; 2020.</p><p>This homework wasn’t easy as I tried several days to figure out from other seniors’ works prior to our lecture tonight. I reckon one essential thing is to connect the designated UI elements via the code I wrote in the func. Here is what one should pay attention to :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lL-a4tZImq6rndPAzIKNag.png" /></figure><p>Now, let’s take a look at the code I added to make some <strong>outlets and actions </strong>work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CdYEgA3TOnsj-Eb4bcz-QQ.png" /><figcaption><strong>Part 1</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hQcr2-CXm8QZhSWzPLmbJQ.png" /><figcaption><strong>Part 2</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DqnlEvZGwIq84GfrYumlA.png" /><figcaption><strong>Part 3</strong></figcaption></figure><p>By the way, in case sometimes you don’t see the assistant editor when you want to write the code. You can go to the menu to do as follows: <strong>Xcode →View →Reset Assistant Selection</strong>. Or you can close Xcode and run it again. I didn’t see the assistant editor at the beginning, so I went to View to select Reset Assistant Selection and it worked.</p><p>Lastly, let’s take a look at how it works on the Simulator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*n_BhJ4HPIXLj9ECYy25Ozw.gif" /></figure><p>It’s not the best design as I’m not that artistic and still trying to practice how to be adept at these new skills. There are other things I can add and I think I will do that for my future practice. As time goes by I shall become more familiar with what we have learnt in class. As for the code, I sort of imitated other seniors’ works. Thanks for their examples. Now, I am able to grasp more and more what the wording means in code, especially after Peter’s lecture. It’s awesome, indeed. Until next time, cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b75eb5916c3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/hw-17-practice-using-page-control-segmented-control-button-etc-to-change-contents-b75eb5916c3a">HW#17 Practice using page control，segmented control &amp; button etc. to change contents</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>