{"id":1108,"date":"2018-04-02T09:25:45","date_gmt":"2018-04-02T09:25:45","guid":{"rendered":"http:\/\/sezeromer.com\/?p=1108"},"modified":"2023-02-26T13:43:59","modified_gmt":"2023-02-26T10:43:59","slug":"swift-switch-case-yapisi","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/swift-switch-case-yapisi\/","title":{"rendered":"Swift Switch Case"},"content":{"rendered":"<p>One of the most important features in programming languages is decision making. <strong>Switch<\/strong> <strong>Case<\/strong> is the most used in decision making. <strong>Java<\/strong> and <strong>C #<\/strong> are different again according to <strong>Swift<\/strong>. We have also mentioned the decision of \u0130f Else, which is a spontaneous decision structure in our previous courses. In this article, I will describe the switch case structure on a sample application. In this scenario we will get a random number. We will then print the spelling of this number on the screen. you can find each topic in this example application in the previous postings.<\/p>\n<p>First we must create a random number. You can see how I created random numbers in the previous article. We should be careful, the random number should be in a certain range so that our work is easier. I&#8217;ll get the numbers up to 10. Then we write a switch to write the name of the variable to be executed on which variable. Then, with the case options, we predict what values this variable will take and write what happens when it gets those values.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">let rastgeleSayi = arc4random_uniform(10)\r\n        switch rastgeleSayi {\r\n        case 0:\r\n            label1.text=\"S\u0131f\u0131r\"\r\n            break\r\n        case 1 :\r\n            label1.text=\"Bir\"\r\n            break\r\n        case 2 :\r\n            label1.text=\"\u0130ki\"\r\n            break\r\n        case 3 :\r\n            label1.text=\"\u00dc\u00e7\"\r\n            break\r\n        case 4 :\r\n            label1.text=\"D\u00f6rt\"\r\n            break\r\n        case 5:\r\n            label1.text=\"Be\u015f\"\r\n            break\r\n        case 6:\r\n            label1.text = \"Alt\u0131\"\r\n            break\r\n        case 7:\r\n            label1.text=\"Yedi\"\r\n            break\r\n        case 8 :\r\n            label1.text=\"Sekiz\"\r\n            break\r\n        case 9 :\r\n            label1.text=\"Dokuz\"\r\n            break\r\n        default:\r\n            break\r\n        }<\/pre>\n<\/div>\n<p>I am using the random number variable that I created in this example, and I print this screen as the number which comes up. The simplest and most useful way to do this with the if-else construct is to use a switch-case construct that would be unnecessarily long and absurd.<\/p>\n<p>If you have any questions that you have in mind, you can reach me by email or comment.<\/p>","protected":false},"excerpt":{"rendered":"<p>One of the most important features in programming languages is decision making. Switch Case is the most used in decision making. Java and C # are different again according to Swift. We have also mentioned the decision of \u0130f Else, which is a spontaneous decision structure in our previous courses. In this article, I will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1110,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[327],"tags":[369,331,349,348,115,7,365,328,143,368],"class_list":["post-1108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift","tag-case","tag-degisken","tag-else","tag-if","tag-ios","tag-omer-sezer","tag-random","tag-swift","tag-switch","tag-switchr"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/1108"}],"collection":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/comments?post=1108"}],"version-history":[{"count":3,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/1108\/revisions"}],"predecessor-version":[{"id":2581,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/1108\/revisions\/2581"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/1110"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=1108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=1108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=1108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}