{"id":1134,"date":"2016-06-10T11:12:49","date_gmt":"2016-06-10T04:12:49","guid":{"rendered":"http:\/\/www.booboohome.com\/blogs\/?p=1134"},"modified":"2025-08-10T16:02:20","modified_gmt":"2025-08-10T09:02:20","slug":"ios-tutorial-begin-with-swift-day-3","status":"publish","type":"post","link":"https:\/\/www.booboohome.com\/blogs\/2016\/06\/ios-tutorial-begin-with-swift-day-3\/","title":{"rendered":"iOS Tutorial &#8211; Begin with swift ( day 3 ) &#8211;  Collection"},"content":{"rendered":"<p><strong>\u0e23\u0e39\u0e49\u0e08\u0e31\u0e01\u0e01\u0e31\u0e1a Collection<\/strong><\/p>\n<p>\u0e43\u0e19 swift \u0e19\u0e31\u0e49\u0e19\u0e08\u0e30\u0e21\u0e35 collection\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e01\u0e31\u0e19 3 \u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e2b\u0e25\u0e31\u0e01\u0e46 \u0e04\u0e37\u0e2d<\/p>\n<ul>\n<li>Array \u0e0b\u0e36\u0e48\u0e07\u0e40\u0e1b\u0e47\u0e19 collection \u0e17\u0e35\u0e48\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e15\u0e32\u0e21\u0e25\u0e33\u0e14\u0e31\u0e1a<\/li>\n<li>Set \u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e21\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e25\u0e33\u0e14\u0e31\u0e1a<\/li>\n<li>Dictionary \u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e21\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e25\u0e33\u0e14\u0e31\u0e1a<\/li>\n<\/ul>\n<p>\u0e40\u0e27\u0e25\u0e32\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 collection \u0e41\u0e1a\u0e1a Array, Set \u0e2b\u0e23\u0e37\u0e2d Dictionary \u0e16\u0e49\u0e32\u0e40\u0e23\u0e32\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 collection \u0e40\u0e2b\u0e25\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19\u0e14\u0e49\u0e27\u0e22 &#8220;var&#8221;(variable) collection \u0e19\u0e31\u0e49\u0e19\u0e08\u0e30\u0e16\u0e39\u0e01\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e1b\u0e47\u0e19\u0e41\u0e1a\u0e1a mutable \u0e04\u0e37\u0e2d\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e21\u0e32\u0e1b\u0e23\u0e31\u0e1a\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e14\u0e49\u0e32\u0e19\u0e43\u0e19\u0e44\u0e14\u0e49\u00a0 \u0e41\u0e15\u0e48\u0e16\u0e49\u0e32\u0e40\u0e27\u0e25\u0e32\u0e2a\u0e23\u0e49\u0e32\u0e07 collection \u0e40\u0e2b\u0e25\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19\u0e14\u0e49\u0e27\u0e22 &#8220;let&#8221;(constant) \u0e41\u0e25\u0e49\u0e27\u0e25\u0e30\u0e01\u0e47 collection \u0e01\u0e47\u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e41\u0e1a\u0e1a immutable \u0e04\u0e37\u0e2d\u0e44\u0e21\u0e48\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e41\u0e1b\u0e25\u0e07\u0e41\u0e01\u0e49\u0e44\u0e02\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e14\u0e49\u0e2d\u0e35\u0e01\u0e41\u0e25\u0e49\u0e27<\/p>\n<ol>\n<li><strong>Array<\/strong>\u00a0 \u0e08\u0e30\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e01\u0e47\u0e1a\u0e04\u0e48\u0e32\u0e17\u0e35\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e0a\u0e19\u0e34\u0e14\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e25\u0e07\u0e44\u0e1b \u0e41\u0e25\u0e30\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e1a\u0e1a\u0e40\u0e23\u0e35\u0e22\u0e07\u0e25\u0e33\u0e14\u0e31\u0e1a \u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e2b\u0e19\u0e21\u0e32\u0e01\u0e48\u0e2d\u0e19\u0e43\u0e2a\u0e48\u0e01\u0e48\u0e2d\u0e19 \u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e2b\u0e19\u0e21\u0e32\u0e2b\u0e25\u0e31\u0e07\u0e08\u0e30\u0e43\u0e2a\u0e48\u0e17\u0e35\u0e2b\u0e25\u0e31\u0e07 \u0e41\u0e25\u0e30 \u0e04\u0e48\u0e32\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e01\u0e47\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e16\u0e39\u0e01\u0e1a\u0e23\u0e23\u0e08\u0e38\u0e25\u0e07\u0e44\u0e1b\u0e2b\u0e25\u0e32\u0e22\u0e04\u0e23\u0e31\u0e49\u0e07\u0e43\u0e19 collection \u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e44\u0e14\u0e49\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e43\u0e19 swift \u0e2d\u0e32\u0e08\u0e43\u0e0a\u0e49 Array&lt;Element&gt; \u0e2b\u0e23\u0e37\u0e2d\u0e40\u0e02\u0e35\u0e22\u0e19\u0e43\u0e19\u0e23\u0e39\u0e1b\u0e22\u0e48\u0e2d\u0e44\u0e14\u0e49\u0e04\u0e37\u0e2d [Element] \u0e41\u0e21\u0e49\u0e27\u0e48\u0e32\u0e17\u0e31\u0e49\u0e07\u0e2a\u0e2d\u0e07\u0e41\u0e1a\u0e1a\u0e08\u0e30\u0e43\u0e2b\u0e49\u0e1c\u0e25\u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19\u0e01\u0e31\u0e19 \u0e41\u0e15\u0e48\u0e01\u0e32\u0e23\u0e40\u0e02\u0e35\u0e22\u0e19\u0e41\u0e1a\u0e1a\u0e22\u0e48\u0e2d\u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e17\u0e35\u0e48\u0e19\u0e34\u0e22\u0e21\u0e21\u0e32\u0e01\u0e01\u0e27\u0e48\u0e32<strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array<\/strong>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var myMealToday    = Array&lt;String&gt;()\r\nvar myMealTomorrow = [String]()<\/pre>\n<p>\u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01 swift \u0e19\u0e31\u0e49\u0e19\u0e21\u0e35 type inference \u0e40\u0e1e\u0e23\u0e32\u0e30\u0e09\u0e30\u0e19\u0e31\u0e49\u0e19 \u0e15\u0e2d\u0e19\u0e1b\u0e23\u0e30\u0e01\u0e32\u0e28\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23 var mealToday \u0e40\u0e23\u0e32\u0e2d\u0e32\u0e08\u0e22\u0e31\u0e07\u0e44\u0e21\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e1b\u0e23\u0e30\u0e01\u0e32\u0e28\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e02\u0e2d\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e01\u0e47\u0e44\u0e14\u0e49 \u0e40\u0e1e\u0e23\u0e32\u0e30 \u0e2b\u0e25\u0e31\u0e01\u0e08\u0e32\u0e01\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e48\u0e32\u0e43\u0e2b\u0e49\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e19\u0e31\u0e49\u0e19\u0e41\u0e25\u0e49\u0e27 \u0e0a\u0e19\u0e34\u0e14\u0e02\u0e2d\u0e07\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e08\u0e30\u0e16\u0e39\u0e01\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e40\u0e2d\u0e07\u0e15\u0e32\u0e21\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e02\u0e2d\u0e07\u0e04\u0e48\u0e32\u0e17\u0e35\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e19\u0e31\u0e49\u0e19<\/p>\n<p>\u0e15\u0e31<strong>\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e41\u0e25\u0e30\u0e04\u0e48\u0e32\u0e15\u0e31\u0e49\u0e07\u0e15\u0e49\u0e19<\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var scores = [Int](count:50, repeatedValue:0)<\/pre>\n<p>\u0e08\u0e32\u0e01\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e02\u0e49\u0e32\u0e07\u0e15\u0e49\u0e19\u0e04\u0e37\u0e2d \u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e42\u0e14\u0e22\u0e21\u0e35\u0e04\u0e48\u0e32\u0e15\u0e31\u0e49\u0e07\u0e15\u0e49\u0e19 \u0e08\u0e32\u0e01\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e43\u0e2b\u0e49\u0e21\u0e35\u0e02\u0e19\u0e32\u0e14(count)\u00a0 50 \u0e41\u0e25\u0e30\u0e04\u0e48\u0e32 default(repeatedValue) \u0e17\u0e38\u0e01\u0e15\u0e31\u0e27\u0e04\u0e37\u0e2d 0<\/p>\n<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e41\u0e1a\u0e1a\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e48\u0e32<\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var studentRoomA : [String] = [\"David\", \"Peter\", \"John\"]     \/\/ \u0e01\u0e33\u0e2b\u0e19\u0e14 type \u0e02\u0e2d\u0e07 Array\r\nvar studentRoomB            = [\"Frank\", \"James\", \"Anna\"]     \/\/ \u0e44\u0e21\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14 type \u0e02\u0e2d\u0e07 Array \u0e43\u0e0a\u0e49swift's type inference \u0e01\u0e33\u0e2b\u0e19\u0e14\u0e43\u0e2b\u0e49\u0e40\u0e1b\u0e47\u0e19 Array \u0e02\u0e2d\u0e07 String<\/pre>\n<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e43\u0e19 Array<br \/>\n<\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var studentRoomA : [String] = [\"David\", \"Peter\", \"John\"]\r\nvar studentRoomB            = [\"Frank\", \"James\", \"Anna\"]\r\nprint(\"Room A has students:\\(studentRoomA.count)\") \/\/ Result: 3\r\n\r\n\/\/ New student attend room A\r\nstudentRoomA.append(\"Nick\");\r\nprint(studentRoomA)                               \/\/ Result: [\"David\", \"Peter\", \"John\", \"Nick\"]\r\n\r\n\/\/ First student left room A\r\nstudentRoomA.removeAtIndex(0)\r\nprint(studentRoomA)                               \/\/ Result: [\"Peter\", \"John\", \"Nick\"]<\/pre>\n<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e27\u0e19\u0e14\u0e39\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19 Array<\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var studentRoomA : [String] = [\"David\", \"Peter\", \"John\"]\r\nfor student in studentRoomA{\r\n    print(student)\r\n}<\/pre>\n<\/li>\n<li>\u00a0Set \u0e43\u0e0a\u0e49\u0e40\u0e01\u0e47\u0e1a\u0e04\u0e48\u0e32\u0e02\u0e2d\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19 \u0e41\u0e1a\u0e1a\u0e44\u0e21\u0e48\u0e40\u0e23\u0e35\u0e22\u0e07\u0e15\u0e32\u0e21\u0e25\u0e33\u0e14\u0e31\u0e1a \u0e41\u0e25\u0e30\u0e41\u0e15\u0e48\u0e25\u0e30\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e41\u0e15\u0e01\u0e15\u0e48\u0e32\u0e07\u0e01\u0e31\u0e19 \u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49 Set \u0e41\u0e17\u0e19 Array \u0e01\u0e47\u0e15\u0e48\u0e2d\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e25\u0e33\u0e14\u0e31\u0e1a\u0e02\u0e2d\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e21\u0e48\u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e2a\u0e33\u0e04\u0e31\u0e0d \u0e2b\u0e23\u0e37\u0e2d\u0e2d\u0e32\u0e08\u0e43\u0e0a\u0e49\u0e01\u0e47\u0e15\u0e48\u0e2d\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e21\u0e31\u0e48\u0e19\u0e43\u0e08\u0e27\u0e48\u0e32\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e19\u0e31\u0e49\u0e19\u0e46 \u0e21\u0e35\u0e41\u0e04\u0e48\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e40\u0e14\u0e35\u0e22\u0e27\u0e43\u0e19 collection<br \/>\n\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Set \u0e40\u0e02\u0e35\u0e22\u0e19\u0e44\u0e14\u0e49\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49 Set&lt;Element&gt;<br \/>\n<strong><strong><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e0b\u0e15\u0e40\u0e1b\u0e25\u0e48\u0e32<\/strong><\/strong><\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var fruitInAnnaBasket = Set&lt;String&gt;()<\/pre>\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e0b\u0e15\u0e08\u0e32\u0e01 array<\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var fruitInMyBasket:Set&lt;String&gt; = [\"banana\", \"mango\", \"apple\"]   \/\/ \u0e41\u0e1a\u0e1a\u0e17\u0e35\u0e48 1\r\nvar fruitInPeterBasket:Set      = [\"banana\", \"mango\", \"apple\"]   \/\/ \u0e41\u0e1a\u0e1a\u0e17\u0e35\u0e48 2<\/pre>\n<p>\u0e08\u0e32\u0e01\u0e41\u0e1a\u0e1a\u0e17\u0e35\u0e48 1 \u0e40\u0e23\u0e32\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e02\u0e2d\u0e07 Set \u0e44\u0e1b\u0e43\u0e2b\u0e49\u0e15\u0e2d\u0e19\u0e1b\u0e23\u0e30\u0e01\u0e32\u0e28\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23 Set&lt;String&gt; \u0e43\u0e19\u0e41\u0e1a\u0e1a\u0e17\u0e35\u0e48 2 \u0e40\u0e23\u0e32\u0e44\u0e21\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e02\u0e2d\u0e07\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e25\u0e07\u0e44\u0e1b\u0e01\u0e47\u0e44\u0e14\u0e49 \u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01 swift&#8217;s type inference \u0e41\u0e15\u0e48\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e15\u0e49\u0e2d\u0e07\u0e40\u0e02\u0e35\u0e22\u0e19 Set \u0e01\u0e33\u0e01\u0e31\u0e1a\u0e25\u0e07\u0e44\u0e1b\u0e40\u0e1e\u0e23\u0e32\u0e30\u0e2b\u0e32\u0e01\u0e44\u0e21\u0e48\u0e43\u0e2a\u0e48 swift \u0e40\u0e2d\u0e07\u0e08\u0e30\u0e2a\u0e31\u0e1a\u0e2a\u0e19\u0e23\u0e30\u0e2b\u0e27\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e1b\u0e23\u0e30\u0e01\u0e32\u0e28 Set \u0e41\u0e25\u0e30 Array<\/p>\n<p><strong>\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e17\u0e35\u0e48\u0e43\u0e0a\u0e49\u0e01\u0e31\u0e1a Set \u0e44\u0e14\u0e49<\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var fruitInAnnaBasket = Set&lt;String&gt;()\r\nfruitInAnnaBasket.insert(\"pomelo\")\r\nfruitInAnnaBasket.insert(\"grape\")\r\nprint(fruitInAnnaBasket)             \/\/ Result: [\"pomelo\", \"grape\"]\r\n\r\nif !fruitInAnnaBasket.contains(\"orange\") {\r\n    fruitInAnnaBasket.insert(\"orange\")\r\n}\r\nprint(fruitInAnnaBasket)            \/\/ Result:  [\"pomelo\", \"grape\", \"orange\"]<\/pre>\n<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e27\u0e19\u0e14\u0e39\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19 Set<\/strong><\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var fruitInMyBasket:Set&lt;String&gt; = [\"banana\", \"mango\", \"apple\"]\r\nfor fruit in fruitInMyBasket {\r\n    print(\"I can eat \\(fruit)\")\r\n}<\/pre>\n<p><strong>Operation \u0e17\u0e35\u0e48\u0e43\u0e0a\u0e49\u0e43\u0e19 Set \u0e44\u0e14\u0e49<br \/>\n<a href=\"https:\/\/www.booboohome.com\/blogs\/wp-content\/uploads\/2016\/06\/set_operation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1145\" src=\"https:\/\/www.booboohome.com\/blogs\/wp-content\/uploads\/2016\/06\/set_operation.png\" alt=\"set_operation\" width=\"613\" height=\"455\" srcset=\"https:\/\/www.booboohome.com\/blogs\/wp-content\/uploads\/2016\/06\/set_operation.png?v=1766667971 613w, https:\/\/www.booboohome.com\/blogs\/wp-content\/uploads\/2016\/06\/set_operation-120x90.png?v=1766667971 120w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/a><\/strong><\/li>\n<li>\u00a0Dictionary \u0e43\u0e0a\u0e49\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 key, value \u0e02\u0e2d\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e44\u0e27\u0e49\u0e42\u0e14\u0e22\u0e44\u0e21\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e07\u0e25\u0e33\u0e14\u0e31\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 \u0e40\u0e23\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49 Dictionary \u0e01\u0e47\u0e15\u0e49\u0e2d\u0e07\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e40\u0e23\u0e32\u0e15\u0e49\u0e2d\u0e07\u0e17\u0e33\u0e01\u0e32\u0e23\u0e04\u0e49\u0e19\u0e2b\u0e32\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e08\u0e32\u0e01 key \u0e17\u0e35\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e44\u0e27\u0e49 \u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23\u0e19\u0e31\u0e49\u0e19\u0e40\u0e1b\u0e47\u0e19\u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e01\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e04\u0e49\u0e19\u0e2b\u0e32\u0e04\u0e33\u0e28\u0e31\u0e1e\u0e17\u0e4c\u0e08\u0e32\u0e01\u0e14\u0e34\u0e01\u0e0a\u0e31\u0e19\u0e19\u0e32\u0e23\u0e35\u0e20\u0e32\u0e29\u0e32\u0e2d\u0e31\u0e07\u0e01\u0e24\u0e29\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e04\u0e49\u0e19\u0e2b\u0e32\u0e04\u0e27\u0e32\u0e21\u0e2b\u0e21\u0e32\u0e22\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u00a0 \u0e27\u0e34\u0e18\u0e35\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Dicitionary&lt;key, value&gt; \u0e2b\u0e23\u0e37\u0e2d\u0e41\u0e1a\u0e1a\u0e22\u0e48\u0e2d\u0e01\u0e47\u0e04\u0e37\u0e2d [key:value] \u0e17\u0e31\u0e49\u0e07\u0e2a\u0e2d\u0e07\u0e41\u0e1a\u0e1a\u0e08\u0e30\u0e43\u0e2b\u0e49\u0e1c\u0e25\u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19\u0e01\u0e31\u0e19 \u0e41\u0e15\u0e48\u0e41\u0e1a\u0e1a\u0e22\u0e48\u0e2d\u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e17\u0e35\u0e48\u0e19\u0e34\u0e22\u0e21\u0e21\u0e32\u0e01\u0e01\u0e27\u0e48\u0e32\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Dictionary\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var contacts1 = [String:String]()\r\nvar contacts2 = Dictionary&lt;String, String&gt;()<\/pre>\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Dictionary \u0e1e\u0e23\u0e49\u0e2d\u0e21\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e48\u0e32<\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var contacts:[String:String] = [\"David\": \"David@booboohome.com\", \"Peter\": \"Peter@booboohome.com\",\"John\": \"John@booboohome.com\"]<\/pre>\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e17\u0e35\u0e48\u0e43\u0e0a\u0e49\u0e44\u0e14\u0e49<\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">var contacts:[String:String] = [\"David\": \"David@booboohome.com\", \"Peter\": \"Peter@booboohome.com\",\"John\": \"John@booboohome.com\"]\r\nprint(\"Amount: \\(contacts.count)\")\r\ncontacts[\"David\"] = \"David.Bay@booboohome.com\"      \/\/ change email for David\r\ncontacts.updateValue(\"Peter.West@booboohome.com\", forKey: \"Peter\")  \/\/ change email for Peter\r\ncontacts[\"John\"] = nil                  \/\/ remove John from Dictionary\r\ncontacts.removeValueForKey(\"Peter\")     \/\/ remove Peter from Dictionary\r\nprint(contacts)                         \/\/ Result:      [\"David\": \"David.Bay@booboohome.com\"]<\/pre>\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e27\u0e19\u0e14\u0e39\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19 Dictionary<\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">for(name, email) in contacts{\r\n    print(\"Name:\\(name) , Email:\\(email)\")\r\n}<\/pre>\n<p>\u0e1c\u0e25\u0e01\u0e47\u0e04\u0e37\u0e2d<\/p>\n<pre class=\"prettyprint lang-swift\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">Name:David , Email:David.Bay@booboohome.com<\/pre>\n<p><a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/Swift\/Conceptual\/Swift_Programming_Language\/CollectionTypes.html#\/\/apple_ref\/doc\/uid\/TP40014097-CH8-ID105\">\u0e2d\u0e48\u0e32\u0e19\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21 <\/a><\/p>\n<p>\u0e27\u0e31\u0e19\u0e15\u0e48\u0e2d\u0e44\u0e1b -&gt; <a href=\"https:\/\/www.booboohome.com\/blogs\/2016\/06\/ios-tutorial-begin-with-swift-day-4\/\">Function<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u0e23\u0e39\u0e49\u0e08\u0e31\u0e01\u0e01\u0e31\u0e1a Collection \u0e43\u0e19 swift \u0e19\u0e31\u0e49\u0e19\u0e08\u0e30\u0e21\u0e35 collection\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e01\u0e31\u0e19 3 \u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e2b\u0e25\u0e31\u0e01\u0e46 \u0e04\u0e37\u0e2d Array \u0e0b\u0e36\u0e48\u0e07\u0e40\u0e1b\u0e47\u0e19 collection \u0e17\u0e35\u0e48\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e15\u0e32\u0e21\u0e25\u0e33\u0e14\u0e31\u0e1a Set \u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e21\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e25\u0e33\u0e14\u0e31\u0e1a Dictionary \u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e21\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e25\u0e33\u0e14\u0e31\u0e1a \u0e40\u0e27\u0e25\u0e32\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 collection \u0e41\u0e1a\u0e1a Array, Set \u0e2b\u0e23\u0e37\u0e2d Dictionary \u0e16\u0e49\u0e32\u0e40\u0e23\u0e32\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 collection \u0e40\u0e2b\u0e25\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19\u0e14\u0e49\u0e27\u0e22 &#8220;var&#8221;(variable) collection \u0e19\u0e31\u0e49\u0e19\u0e08\u0e30\u0e16\u0e39\u0e01\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e1b\u0e47\u0e19\u0e41\u0e1a\u0e1a mutable \u0e04\u0e37\u0e2d\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e21\u0e32\u0e1b\u0e23\u0e31\u0e1a\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e14\u0e49\u0e32\u0e19\u0e43\u0e19\u0e44\u0e14\u0e49\u00a0 \u0e41\u0e15\u0e48\u0e16\u0e49\u0e32\u0e40\u0e27\u0e25\u0e32\u0e2a\u0e23\u0e49\u0e32\u0e07 collection \u0e40\u0e2b\u0e25\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19\u0e14\u0e49\u0e27\u0e22 &#8220;let&#8221;(constant) \u0e41\u0e25\u0e49\u0e27\u0e25\u0e30\u0e01\u0e47 collection \u0e01\u0e47\u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e41\u0e1a\u0e1a immutable \u0e04\u0e37\u0e2d\u0e44\u0e21\u0e48\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e41\u0e1b\u0e25\u0e07\u0e41\u0e01\u0e49\u0e44\u0e02\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e14\u0e49\u0e2d\u0e35\u0e01\u0e41\u0e25\u0e49\u0e27 Array\u00a0 \u0e08\u0e30\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e01\u0e47\u0e1a\u0e04\u0e48\u0e32\u0e17\u0e35\u0e48\u0e40\u0e1b\u0e47\u0e19\u0e0a\u0e19\u0e34\u0e14\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e25\u0e07\u0e44\u0e1b \u0e41\u0e25\u0e30\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e1a\u0e1a\u0e40\u0e23\u0e35\u0e22\u0e07\u0e25\u0e33\u0e14\u0e31\u0e1a \u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e2b\u0e19\u0e21\u0e32\u0e01\u0e48\u0e2d\u0e19\u0e43\u0e2a\u0e48\u0e01\u0e48\u0e2d\u0e19 \u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e2b\u0e19\u0e21\u0e32\u0e2b\u0e25\u0e31\u0e07\u0e08\u0e30\u0e43\u0e2a\u0e48\u0e17\u0e35\u0e2b\u0e25\u0e31\u0e07 \u0e41\u0e25\u0e30 \u0e04\u0e48\u0e32\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e01\u0e47\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e16\u0e39\u0e01\u0e1a\u0e23\u0e23\u0e08\u0e38\u0e25\u0e07\u0e44\u0e1b\u0e2b\u0e25\u0e32\u0e22\u0e04\u0e23\u0e31\u0e49\u0e07\u0e43\u0e19 collection \u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e44\u0e14\u0e49\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e43\u0e19 swift \u0e2d\u0e32\u0e08\u0e43\u0e0a\u0e49 Array&lt;Element&gt; <a href=\"https:\/\/www.booboohome.com\/blogs\/2016\/06\/ios-tutorial-begin-with-swift-day-3\/\" rel=\"nofollow\"><span class=\"sr-only\">Read more about iOS Tutorial &#8211; Begin with swift ( day 3 ) &#8211;  Collection<\/span>[&hellip;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":1126,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[75,74,77,76,68,72,73,70],"class_list":["post-1134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios-tutorial","tag-array","tag-collection","tag-dictionary","tag-set","tag-swift","tag-swift-","tag--swift"],"_links":{"self":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts\/1134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/comments?post=1134"}],"version-history":[{"count":19,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts\/1134\/revisions"}],"predecessor-version":[{"id":3579,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/posts\/1134\/revisions\/3579"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/media\/1126"}],"wp:attachment":[{"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/media?parent=1134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/categories?post=1134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.booboohome.com\/blogs\/wp-json\/wp\/v2\/tags?post=1134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}