<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yipcodes</title>
    <description>The latest articles on DEV Community by yipcodes (@yipkayan).</description>
    <link>https://dev.to/yipkayan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F818137%2F0632e844-3084-4d3e-ab32-6692acc500f0.png</url>
      <title>DEV Community: yipcodes</title>
      <link>https://dev.to/yipkayan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yipkayan"/>
    <language>en</language>
    <item>
      <title>Swift Codable Protocol</title>
      <dc:creator>yipcodes</dc:creator>
      <pubDate>Wed, 21 Jun 2023 03:56:12 +0000</pubDate>
      <link>https://dev.to/yipkayan/swift-codable-protocol-1cp9</link>
      <guid>https://dev.to/yipkayan/swift-codable-protocol-1cp9</guid>
      <description>&lt;p&gt;&lt;strong&gt;KISS: Codable protocol helps to translate json data format into a class object.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;KISS Diagram:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8OM11Woj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gqa50mgp3p68b6tw8qf6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8OM11Woj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gqa50mgp3p68b6tw8qf6.png" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a short extraction from this well written &lt;a href="https://www.wundermanthompson.com/insight/swift-codable-protocol-part-i#:~:text=Codable%20is%20the%20combined%20protocol,to%20be%20saved%20or%20transferred."&gt;article by wunderman thomson&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Codable is the combined protocol of Swift’s Decodable and Encodable protocols. Together they provide standard methods of decoding data for custom types and encoding data to be saved or transferred. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Below is an example of just how simple Codable can make the data parsing process. Notice that the first object, parsed without Codable, takes about 19 lines of code. The second object, using Codable, takes just 5 lines of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// JSON Data:
{
 "id": 1234,
 "src": "//api.someHost.com/version/someImageName.jpg",
 "caption": null
}


// Old Object:
struct Photo {
 let id: Int
 let src: URL
 let caption: String?

 init?(json: [String: Any]) {
 guard
 let id = json[“id”] as? Int,
 let srcString = json["src"] as? String,
 let src = URL(string: srcString)
 else { return nil }

 let caption = json["caption"] as? String

 self.id = id
 self.src = src
 self.caption = caption
 }
}


// New Codable Object:
struct Photo: Codable {
 let id: Int
 let src: URL
 let caption: String?
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>swift</category>
      <category>codable</category>
    </item>
    <item>
      <title>Play sound in SWIFT 5</title>
      <dc:creator>yipcodes</dc:creator>
      <pubDate>Wed, 15 Jun 2022 08:37:45 +0000</pubDate>
      <link>https://dev.to/yipkayan/play-sound-in-swift-5-49p3</link>
      <guid>https://dev.to/yipkayan/play-sound-in-swift-5-49p3</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import AVKit

class ViewController: UIViewController {
    var player: AVAudioPlayer?

    @IBAction func buttonPressed(_ sender: UIButton) {
        playSound(soundTitle:sender.currentTitle!)
    }

    func playSound(soundTitle:String) {
        let path = Bundle.main.path(forResource: "soundName",ofType:"mp3")

        let url = URL(fileURLWithPath: path!)

        do {
            player = try AVAudioPlayer(contentsOf: url)
            player?.play()

        } catch let error {
            print(error.localizedDescription)
        }
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>HTML Boilerplate</title>
      <dc:creator>yipcodes</dc:creator>
      <pubDate>Mon, 06 Jun 2022 08:47:42 +0000</pubDate>
      <link>https://dev.to/yipkayan/html-boilerplate-4h0h</link>
      <guid>https://dev.to/yipkayan/html-boilerplate-4h0h</guid>
      <description>&lt;h2&gt;
  
  
  HTML Boilerplate
&lt;/h2&gt;

&lt;p&gt;Below is the standard html 5 code template, which is also known as a boilerplate. Something that can be reuse for different project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;

  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The DOCTYPE
&lt;/h2&gt;

&lt;p&gt;The doctype declaration tells the browser to render as an HTML 5 document.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  HTML Tag
&lt;/h2&gt;

&lt;p&gt;The html tag tells the browser that between html opening and closing tags is going to be a html code. The html tag consist of head and body tags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  HEAD tag
&lt;/h2&gt;

&lt;p&gt;The head tag holds the information about the web page, and tells the browser how to handle the page. It can display a title for the website, as well as setting the meta data charset to a specific encoding.&lt;/p&gt;

&lt;p&gt;The standard charset for encoding is "utf-8".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the older browser, different languages uses different symbols, thus the encoding might be different and become unreadable if the browser set the unicode wrongly. At the present, most of the browser is using standard "utf-8", as it contains all the standard international symbols for all different languages.&lt;/p&gt;

&lt;p&gt;This &lt;a href="https://unicode-table.com/en/"&gt;link&lt;/a&gt; contains all the unicode character for "utf-8", ranging from different languages and even emojis 💙.&lt;/p&gt;

&lt;p&gt;Here is an &lt;a href="https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/"&gt;article&lt;/a&gt; on more details about unicode.&lt;/p&gt;




&lt;h2&gt;
  
  
  More about META tag
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta name="description" content="Free Web tutorials"&amp;gt;
  &amp;lt;meta name="keywords" content="HTML, CSS, JavaScript"&amp;gt;
  &amp;lt;meta name="author" content="John Doe"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;more about meta tag can be found &lt;a href="https://www.w3schools.com/tags/tag_meta.asp"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are other meta elements that we can set, for example the viewport which set how the webpage scale and display accordingly to the devices (mobile responsive).&lt;/p&gt;

&lt;p&gt;The description are the information that the search engine crawl and search the web description and display it. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R54Pr_pL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0leceksi2agpoupcqch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R54Pr_pL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0leceksi2agpoupcqch.png" alt="Image description" width="880" height="192"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  BODY tag
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Body tag contains all the contents of an HTML document, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.&lt;/p&gt;




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

&lt;p&gt;Every html page should have a html boilerplate template. It should contains the doctype, meta, title and an empty body tag to get ready for content coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
    </item>
  </channel>
</rss>
