{"id":37498,"date":"2016-07-10T18:15:34","date_gmt":"2016-07-10T12:45:34","guid":{"rendered":"https:\/\/2thenew.today\/blog\/?p=37498"},"modified":"2016-07-20T12:56:54","modified_gmt":"2016-07-20T07:26:54","slug":"swift-for-loops","status":"publish","type":"post","link":"https:\/\/2thenew.today\/blog\/swift-for-loops\/","title":{"rendered":"Swift For-Loops"},"content":{"rendered":"<p>In Swift 3.0 C-style for-loops will be removed. This will force <a title=\"iOS app developers\" href=\"https:\/\/2thenew.today\/mobile-ios-application-development-services\">developers<\/a> to use a swift syntax for for-loops. So lets begin with swift for loops :<\/p>\n<ul>\n<li>Looping n times<\/li>\n<\/ul>\n<p>[code language=&#8221;objc&#8221;]<br \/>\n\/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9<br \/>\nfor i in 0..&lt;10 {<br \/>\n\tprint(i)<br \/>\n}<br \/>\n\/\/ or<br \/>\nfor i in 0&#8230;9 {<br \/>\n\tprint(i)<br \/>\n}<br \/>\n[\/code]<\/p>\n<ul>\n<li>Looping n times in reverse<\/li>\n<\/ul>\n<p>[code language=&#8221;objc&#8221;]<br \/>\n\/\/ output is 10, 9, 8, 7, 6, 5, 4, 3, 2, 1<br \/>\nfor i in (1&#8230;10).reverse() {<br \/>\n    print(i)<br \/>\n}<br \/>\n[\/code]<\/p>\n<ul>\n<li>Looping through Array Values<\/li>\n<\/ul>\n<p>[code language=&#8221;objc&#8221;]<br \/>\n\/\/ output is: ashu, amit, deepak<br \/>\nlet namesArray = [&quot;ashu&quot;, &quot;amit&quot;, &quot;deepak&quot;]<br \/>\nfor name in namesArray {<br \/>\n    print(name)<br \/>\n}<br \/>\n[\/code]<\/p>\n<ul>\n<li>Looping through Dictionary Values<\/li>\n<\/ul>\n<p>[code language=&#8221;objc&#8221;]<br \/>\n\/\/ output is key is age &amp; value is 24, key is profession &amp; value is software development, key is name &amp; value is ashu<br \/>\nlet infoDict = [&quot;name&quot;: &quot;ashu&quot;, &quot;age&quot;: &quot;24&quot;, &quot;profession&amp;quot&quot;: &quot;software development&quot;]<br \/>\nfor (key,value) in infoDict {<br \/>\n\tprint(&quot;key is \\(key) &amp; value is \\(value)&quot;)<br \/>\n}<br \/>\n[\/code]<\/p>\n<ul>\n<li>Looping Through an Array with Index<\/li>\n<\/ul>\n<p>[code language=&#8221;objc&#8221;]<br \/>\n\/\/ output is index: 0 &amp; value: ashu, index: 1 &amp; value: amit, index: 2 &amp; value: deepak<br \/>\nlet namesArray = [&quot;ashu&quot;, &quot;amit&quot;, &quot;deepak&quot;]<br \/>\nfor (index,name) in namesArray.enumerate() {<br \/>\n\tprint(&quot;index: \\(index) &amp; value: \\(name)&quot;)<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>Congratulations! you have learned Swift for-loops!!!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=&#8221;objc&#8221;] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..&lt;10 { print(i) } \/\/ or for [&hellip;]<\/p>\n","protected":false},"author":172,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":4,"footnotes":""},"categories":[1400,1772,1],"tags":[3723,3726,3730,3724,3727,3725,3728,4848,3729,2715,3722,3721],"class_list":["post-37498","post","type-post","status-publish","format-standard","hentry","category-ios","category-mobility","category-technology","tag-for","tag-for-each","tag-for-loop-in-swift-3","tag-for-loops","tag-for-each-loops","tag-for-in","tag-for-in-loops","tag-ios","tag-loops","tag-swift","tag-swift-3","tag-swift-3-0"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=&quot;objc&quot;] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Ashu Baweja\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.today\/blog\/swift-for-loops\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Swift For-Loops | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=&quot;objc&quot;] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.today\/blog\/swift-for-loops\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Swift For-Loops | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=&quot;objc&quot;] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#article\",\"name\":\"Swift For-Loops | TO THE NEW Blog\",\"headline\":\"Swift For-Loops\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/ashu-bawejaintelligrape-com\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2016-07-10T18:15:34+05:30\",\"dateModified\":\"2016-07-20T12:56:54+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#webpage\"},\"articleSection\":\"iOS, Mobility, Technology, for, for each, for loop in swift 3, for loops, for-each loops, for-in, for-in loops, iOS, loops, swift, swift 3, swift 3.0\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#listItem\",\"name\":\"Swift For-Loops\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#listItem\",\"position\":3,\"name\":\"Swift For-Loops\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/ashu-bawejaintelligrape-com\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/ashu-bawejaintelligrape-com\\\/\",\"name\":\"Ashu Baweja\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1e832c32f554b88da3e8f8fd33424aa41115be6faff0b06e6a94ebc2c2d0cba?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Ashu Baweja\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/\",\"name\":\"Swift For-Loops | TO THE NEW Blog\",\"description\":\"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=\\\"objc\\\"] \\\/\\\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/swift-for-loops\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/ashu-bawejaintelligrape-com\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/ashu-bawejaintelligrape-com\\\/#author\"},\"datePublished\":\"2016-07-10T18:15:34+05:30\",\"dateModified\":\"2016-07-20T12:56:54+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Swift For-Loops | TO THE NEW Blog","description":"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=\"objc\"] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..","canonical_url":"https:\/\/2thenew.today\/blog\/swift-for-loops\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#article","name":"Swift For-Loops | TO THE NEW Blog","headline":"Swift For-Loops","author":{"@id":"https:\/\/2thenew.today\/blog\/author\/ashu-bawejaintelligrape-com\/#author"},"publisher":{"@id":"https:\/\/2thenew.today\/blog\/#organization"},"datePublished":"2016-07-10T18:15:34+05:30","dateModified":"2016-07-20T12:56:54+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#webpage"},"articleSection":"iOS, Mobility, Technology, for, for each, for loop in swift 3, for loops, for-each loops, for-in, for-in loops, iOS, loops, swift, swift 3, swift 3.0"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.today\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/2thenew.today\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#listItem","name":"Swift For-Loops"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#listItem","position":3,"name":"Swift For-Loops","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.today\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.today\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.today\/blog\/author\/ashu-bawejaintelligrape-com\/#author","url":"https:\/\/2thenew.today\/blog\/author\/ashu-bawejaintelligrape-com\/","name":"Ashu Baweja","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d1e832c32f554b88da3e8f8fd33424aa41115be6faff0b06e6a94ebc2c2d0cba?s=96&d=mm&r=g","width":96,"height":96,"caption":"Ashu Baweja"}},{"@type":"WebPage","@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#webpage","url":"https:\/\/2thenew.today\/blog\/swift-for-loops\/","name":"Swift For-Loops | TO THE NEW Blog","description":"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=\"objc\"] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.today\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.today\/blog\/swift-for-loops\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.today\/blog\/author\/ashu-bawejaintelligrape-com\/#author"},"creator":{"@id":"https:\/\/2thenew.today\/blog\/author\/ashu-bawejaintelligrape-com\/#author"},"datePublished":"2016-07-10T18:15:34+05:30","dateModified":"2016-07-20T12:56:54+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.today\/blog\/#website","url":"https:\/\/2thenew.today\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.today\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Swift For-Loops | TO THE NEW Blog","og:description":"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=&quot;objc&quot;] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..","og:url":"https:\/\/2thenew.today\/blog\/swift-for-loops\/","og:image":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Swift For-Loops | TO THE NEW Blog","twitter:description":"In Swift 3.0 C-style for-loops will be removed. This will force developers to use a swift syntax for for-loops. So lets begin with swift for loops : Looping n times [code language=&quot;objc&quot;] \/\/ output is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 for i in 0..","twitter:image":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"37498","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"blog","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 14:38:12","updated":"2024-02-29 08:47:14","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.today\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.today\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tSwift For-Loops\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.today\/blog"},{"label":"Technology","link":"https:\/\/2thenew.today\/blog\/category\/technology\/"},{"label":"Swift For-Loops","link":"https:\/\/2thenew.today\/blog\/swift-for-loops\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts\/37498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/users\/172"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/comments?post=37498"}],"version-history":[{"count":0,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts\/37498\/revisions"}],"wp:attachment":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/media?parent=37498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/categories?post=37498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/tags?post=37498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}