{"id":390,"date":"2017-06-15T23:59:15","date_gmt":"2017-06-15T14:59:15","guid":{"rendered":"https:\/\/do-gugan.com\/swift\/?p=390"},"modified":"2017-06-17T14:02:40","modified_gmt":"2017-06-17T05:02:40","slug":"%e9%85%8d%e5%88%97-2-%e5%8f%8d%e5%be%a9%e5%87%a6%e7%90%86%e3%82%92%e8%a9%a6%e3%81%99","status":"publish","type":"post","link":"https:\/\/do-gugan.com\/swift\/?p=390","title":{"rendered":"\u914d\u5217 2. \u53cd\u5fa9\u51e6\u7406\u3092\u8a66\u3059"},"content":{"rendered":"<p>for\u6587\u306b\u3088\u308b\u30eb\u30fc\u30d7\u3068\u914d\u5217\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u5b66\u3076\u30b9\u30c6\u30fc\u30b8\u3067\u3059\u3002\u914d\u5217\u306b\u5165\u3063\u3066\u3044\u308b\u3072\u3068\u3064\u3072\u3068\u3064\u306e\u8981\u7d20\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u306b\u5bfe\u3057\u3066\u540c\u3058\u51e6\u7406\u3092\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5168\u304f\u540c\u3058\u51e6\u7406\u3068\u3044\u3046\u3060\u3051\u3067\u306a\u304f\u3001\u8981\u7d20\u6bce\u306e\u9055\u3044\u6d3b\u7528\u3057\u305f\u51e6\u7406\u304c\u3067\u304d\u308b\u306e\u304c\u5f37\u307f\u3067\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3053\u306e\u30b9\u30c6\u30fc\u30b8\u3067\u306f\u30010\u301c5\u756a\u76ee\u306e\u5404\u5217\u306b\u5b9d\u77f3\u3068\u30b9\u30a4\u30c3\u30c1\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002\u4eca\u307e\u3067\u306e\u3084\u308a\u65b9\u3060\u3068\u3001\u3053\u3093\u306a\u98a8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:swift decode:true \" >world.place(Gem(),atColumn:1, row:1)\r\nworld.place(Switch(),atColumn:1, row:1)\r\nworld.place(Gem(),atColumn:2, row:1)\r\nworld.place(Switch(),atColumn:2, row:1)\r\nworld.place(Gem(),atColumn:3, row:1)\r\nworld.place(Switch(),atColumn:3, row:1)\r\nworld.place(Gem(),atColumn:4, row:1)\r\nworld.place(Switch(),atColumn:4, row:1)\r\nworld.place(Gem(),atColumn:5, row:1)\r\nworld.place(Switch(),atColumn:5, row:1)<\/pre>\n<p>\u307b\u307c\u540c\u3058\u30d1\u30bf\u30fc\u30f3\u304c5\u56de\u7e70\u308a\u8fd4\u3055\u308c\u307e\u3059\u304c\u3001\u6b8b\u5ff5\u306a\u304c\u3089atColumn:\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u304c\u9055\u3046\u306e\u3067\u5358\u7d14\u306afor\u6587\u30eb\u30fc\u30d7\u306b\u306f\u3067\u304d\u307e\u305b\u3093\u3002<br \/>\n\u307e\u3055\u306b\u3053\u3093\u306a\u6642\u306b\u3001\u914d\u5217\u3092\u4f7f\u3063\u305f\u7e70\u308a\u8fd4\u3057\u304c\u5f79\u306b\u7acb\u3061\u307e\u3059\u3002<br \/>\n\u540c\u3058for\u3067\u59cb\u307e\u308a\u307e\u3059\u304c\u3001<\/p>\n<pre class=\"lang:swift decode:true \" >\r\nfor (\u30eb\u30fc\u30d7\u5185\u3067\u306e\u5909\u6570\u540d) in (\u914d\u5217\u540d) {\r\n    (\u30eb\u30fc\u30d7\u3055\u305b\u305f\u3044\u51e6\u7406)\r\n}\r\n<\/pre>\n<p>\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002\u3053\u308c\u3067\u300c(\u914d\u5217\u540d)\u306e\u4e2d\u306b\u3042\u308b\u8981\u7d20\u3072\u3068\u3064\u3072\u3068\u3064\u3092(\u30eb\u30fc\u30d7\u5185\u3067\u306e\u5909\u6570\u540d)\u306b\u5165\u308c\u3064\u3064\u3001(\u30eb\u30fc\u30d7\u3055\u305b\u305f\u3044\u51e6\u7406)\u3092\u5b9f\u884c\u300d\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u6b63\u89e3\u4f8b\u306e\u30b3\u30fc\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:swift decode:true \" >\r\n\/\/columns\u3068\u3044\u3046\u914d\u5217\u306b0\u301c5\u306e6\u3064\u306e\u6574\u6570(Int\uff09\u5024\u3092\u5165\u308c\u3066\u304a\u304f\u3002\r\nlet columns = [0, 1, 2, 3, 4, 5]\r\n\r\n\/\/ Give your loop variable a name and pass in your array.\r\nfor column in columns {\r\n    \/\/ Place a gem and a switch for each column.\r\n    \/\/ (\u5404\u5217\u306b\u5b9d\u77f3\u3068\u30b9\u30a4\u30c3\u30c1\u3092\u914d\u7f6e)\r\n    world.place(Gem(), atColumn: column, row: 1)\r\n    world.place(Switch(), atColumn: column, row: 1)\r\n}<\/pre>\n<p>columns\u914d\u5217\u306e\u4e2d\u8eab\u304c\u524d\u304b\u30891\u3064\u305a\u3064\u53d6\u308a\u51fa\u3055\u308c\u3001column\u3068\u3044\u3046\u5909\u6570\u306b\u5165\u308c\u3089\u308c\u3066\u30eb\u30fc\u30d7\u5185\u306e\u51e6\u7406\u304c\u884c\u308f\u308c\u307e\u3059\u30021\u30eb\u30fc\u30d7\u76ee\u306fcolumn\u306e\u4e2d\u8eab\u306f0\u3067\u3059\u3002\u306a\u306e\u3067\u3001world.place\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u306eatColumn:\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306b\u306f0\u3068\u66f8\u3044\u305f\u306e\u3068\u540c\u3058\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066\u6700\u521d\u306e\u30eb\u30fc\u30d7\u304c\u7d42\u308f\u3063\u3066\u7e70\u308a\u8fd4\u3055\u308c\u308b\u6642\u3001column\u306b\u306f2\u756a\u76ee\u306e\u5024\u306e1\u304c\u30bb\u30c3\u30c8\u3055\u308c\u307e\u3059\u3002\u3064\u307e\u308a2\u56de\u76ee\u306e\u30eb\u30fc\u30d7\u3067\u306fatColumn:\u306f1\u306b\u306a\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u3001atColumn:\u304c2,3,4,5\u3068\u5909\u5316\u3057\u306a\u304c\u3089\u7e70\u308a\u8fd4\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002\u6700\u7d42\u7684\u306b\u5168\u3066\u306e\u9678\u5730\u306b\u30b9\u30a4\u30c3\u30c1\u3068\u5b9d\u77f3\u304c\u4e26\u3093\u3067\u3044\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002<br \/>\n\u3053\u306e\u3088\u3046\u306b\u3001\u3061\u3087\u3063\u3068\u305a\u3064\u9055\u3046\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3059\u6642\u306b\u3001\u305d\u306e\u9055\u3046\u90e8\u5206\u3092\u5909\u6570\u306b\u7f6e\u304d\u63db\u3048\u3066\u304a\u304d\u3001\u3053\u306efor\u301cin\u6587\u3067\u6bce\u56de\u5909\u6570\u306e\u4e2d\u8eab\u3092\u5909\u3048\u3066\u3084\u308b\u65b9\u6cd5\u304c\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<script type=\"text\/javascript\">amzn_assoc_ad_type =\"responsive_search_widget\"; amzn_assoc_tracking_id =\"doguganprojec-22\"; amzn_assoc_marketplace =\"amazon\"; amzn_assoc_region =\"JP\"; amzn_assoc_placement =\"\"; amzn_assoc_search_type = \"search_widget\";amzn_assoc_width =\"500\"; amzn_assoc_height =\"400\"; amzn_assoc_default_search_category =\"\"; amzn_assoc_default_search_key =\"iPad\";amzn_assoc_theme =\"light\"; amzn_assoc_bg_color =\"FFFFFF\"; <\/script><script src=\"\/\/z-fe.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1&Marketplace=JP\"><\/script>","protected":false},"excerpt":{"rendered":"<p>for\u6587\u306b\u3088\u308b\u30eb\u30fc\u30d7\u3068\u914d\u5217\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u5b66\u3076\u30b9\u30c6\u30fc\u30b8\u3067\u3059\u3002\u914d\u5217\u306b\u5165\u3063\u3066\u3044\u308b\u3072\u3068\u3064\u3072\u3068\u3064\u306e\u8981\u7d20\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u306b\u5bfe\u3057\u3066\u540c\u3058\u51e6\u7406\u3092\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5168\u304f\u540c\u3058\u51e6\u7406\u3068\u3044\u3046\u3060\u3051\u3067\u306a\u304f\u3001\u8981\u7d20\u6bce\u306e\u9055\u3044\u6d3b\u7528\u3057\u305f\u51e6\u7406\u304c\u3067\u304d\u308b\u306e\u304c\u5f37\u307f\u3067 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/do-gugan.com\/swift\/?p=390\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u914d\u5217 2. \u53cd\u5fa9\u51e6\u7406\u3092\u8a66\u3059&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,17],"tags":[],"class_list":["post-390","post","type-post","status-publish","format-standard","hentry","category-learncode2","category-array"],"_links":{"self":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=390"}],"version-history":[{"count":4,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/390\/revisions"}],"predecessor-version":[{"id":415,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/390\/revisions\/415"}],"wp:attachment":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}