{"id":376,"date":"2024-09-22T00:25:05","date_gmt":"2024-09-22T00:25:05","guid":{"rendered":"https:\/\/xcode15.shimayugu.jp\/?p=376"},"modified":"2024-12-29T07:00:38","modified_gmt":"2024-12-28T22:00:38","slug":"%e6%96%b0swift%e3%81%a7%e8%a1%8c%e3%81%93%e3%81%86%e7%ac%ac%ef%bc%93%ef%bc%96%e5%9b%9e%e3%80%8c%e3%83%90%e3%83%90%e6%8a%9c%e3%81%8d%ef%bc%95%e3%80%8d%e3%80%80%e7%94%b0%e9%83%a8%e4%ba%95","status":"publish","type":"post","link":"https:\/\/xcode15.shimayugu.jp\/?p=376","title":{"rendered":"\u65b0Swift\u3067\u884c\u3053\u3046\u2026\u7b2c\uff13\uff16\u56de\u300c\u30d0\u30d0\u629c\u304d\uff15\u300d\u3000\u7530\u90e8\u4e95\u4fdd"},"content":{"rendered":"\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2473\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/xcode15.shimayugu.jp\/?p=829\">\u89e3\u8aac\u7de8<\/a><\/p>\n\n\n\n<p>\u3000\u3055\u3066\u3001\u4eca\u56de\u3001\u4eca\u307e\u3067\u3042\u307e\u308a\u306b\u3082\u653e\u7f6e\u3057\u3066\u3044\u305f\u3001\u30dc\u30bf\u30f3\u306e\u8868\u793a\u3092\u4f55\u3068\u304b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"1024\" src=\"https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/09\/image-19-541x1024.png\" alt=\"\" class=\"wp-image-377\" srcset=\"https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/09\/image-19-541x1024.png 541w, https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/09\/image-19-158x300.png 158w, https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/09\/image-19-768x1454.png 768w, https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/09\/image-19-811x1536.png 811w, https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/09\/image-19.png 954w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/figure>\n\n\n\n<p>\u3000\u300c\u914d\u5e03\u300d\u30dc\u30bf\u30f3\u3068\u300c\u30da\u30a2\u524a\u9664\u300d\u30dc\u30bf\u30f3\u306b\u3057\u307e\u3057\u305f\u3002\u307e\u305f\u3001Style\u3092Filled\u306b\u3057\u307e\u3057\u305f\u3002\u30dc\u30bf\u30f3\u3092\u9078\u3093\u3067\u3001\u4e00\u756a\u53f3\u306e\u4e0a\u306e\u30a2\u30a4\u30b3\u30f3\u3001\u5de6\u304b\u3089\uff15\u756a\u76ee\u3092\u62bc\u3059\u3068\u30dc\u30bf\u30f3\u306e\u5f62\u72b6\u3092\u8272\u3005\u5909\u66f4\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u6b21\u306b\u30e6\u30fc\u30b6\u30fc\u304c\uff14\u7d44\u306e\u3069\u308c\u3092\u9078\u3076\u304b\u306e\u30dc\u30bf\u30f3\u3092\u4ed8\u3051\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-line=\"19,36-43,49-61\" data-show-lang=\"1\"><code>\/\/\n\/\/  ViewController.swift\n\/\/  baba\n\/\/\n\/\/  Created by \u4fdd Tabei on 2024\/09\/15.\n\/\/\n\nimport UIKit\n\nclass ViewController: UIViewController {\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \/\/ Do any additional setup after loading the view.\n        put53()\n    }\n\n    var eachCard: [[UILabel]] = [[],[],[],[]]\n    var eachButton: [UIButton] = []\n    var cardObj:Card = Card(cdCnt: Card.EnumCard.joker)\n    func put53() {\n        for i in 0 ..&lt; 4 {\n            for j in 0 ..&lt; 14 {\n                let lbl = UILabel(frame: CGRectMake(0, 0, 50, 21))\n                lbl.center = CGPointMake(50 + 40 * CGFloat(j % 7), 150 + 120 * CGFloat(i) +\n                                         50 * CGFloat(j \/ 7))\n                lbl.textAlignment = NSTextAlignment.center\n                if i != 0 && j == 13 {\n                    lbl.text = &quot; &quot;\n                } else {\n                    lbl.text = &quot;\u2b1b\ufe0f&quot;\n                }\n                eachCard[i] += [lbl]\n                self.view.addSubview(lbl)\n            }\n            let btn = UIButton(frame: CGRectMake(0, 0, 50, 21)) as UIButton\n            btn.center = CGPointMake(20, 150 + 120 * CGFloat(i) + 25)\n            btn.setTitle(&quot;\u26aa\ufe0f&quot;, for: .normal)\n            btn.setTitleColor(UIColor.black, for: .normal)\n            btn.addTarget(self, action: #selector(btnTapped), for: .touchUpInside)\n            btn.tag = i\n            eachButton += [btn]\n            self.view.addSubview(btn)\n        }\n        share()\n        show()\n    }\n\n    @objc func btnTapped(sender: UIButton) {\n        for i in 0 ..&lt; 4 {\n            if eachButton[i] == sender {\n                if sender.currentTitle == &quot;\u26aa\ufe0f&quot; {\n                    sender.setTitle(&quot;\u26ab\ufe0f&quot;, for: .normal)\n                } else {\n                    sender.setTitle(&quot;\u26aa\ufe0f&quot;, for: .normal)\n                }\n            } else {\n                eachButton[i].setTitle(&quot;\u26aa\ufe0f&quot;, for: .normal)\n            }\n        }\n    }\n\n    func share() {\n        cardObj.reset()\n        for i in 0 ..&lt; 4 {\n            for j in 0 ..&lt; 14 {\n                if i != 0 && j == 13 {\n                    eachCard[i][j].tag = -1\n                } else {\n                    var ii: Int\n                    ii = cardObj.put()\n                    eachCard[i][j].text = cardObj.disp(card: ii)\n                    eachCard[i][j].tag = ii\n                }\n            }\n        }\n    }\n\n    func show() {\n        for i in 0 ..&lt; 4 {\n            for j in 0 ..&lt; 14 {\n                if eachCard[i][j].tag &gt;= 0 {\n                    eachCard[i][j].text = cardObj.disp(card: eachCard[i][j].tag)\n                } else {\n                    eachCard[i][j].text = &quot;\u3000&quot;\n                }\n            }\n        }\n    }\n\n    @IBAction func btnGoTouch(_ sender: Any) {\n        \/\/for i in 0 ..&lt; 4 {\n        \/\/    for j in 0 ..&lt; 14 {\n        \/\/        if i != 0 && j == 13 {\n        \/\/        } else {\n        \/\/            eachCard[i][j].tag = cardObj.put()\n        \/\/            eachCard[i][j].text = cardObj.disp(card: eachCard[i][j].tag)\n        \/\/        }\n        \/\/    }\n        \/\/}\n        share()\n        show()\n    }\n    \n    @IBAction func btnPairTouch(_ sender: Any) {\n        for i in 0 ..&lt; 4 {\n            for j in 0 ..&lt; 13 {\n                if (eachCard[i][j].tag == 52) || (eachCard[i][j].tag == -1) {\n                    continue\n                }\n                for k in j + 1 ..&lt; 14 {\n                    if (eachCard[i][k].tag == 52) || (eachCard[i][k].tag == -1) {\n                        continue\n                    }\n                    if (eachCard[i][j].tag % 13) == (eachCard[i][k].tag % 13) {\n                        eachCard[i][j].tag = -1\n                        eachCard[i][k].tag = -1\n                        break\n                    }\n                }\n            }\n            var find = false\n            var k = 0\n            for j in 0 ..&lt; 14 {\n                if eachCard[i][j].tag == -1 {\n                    find = true\n                } else {\n                    if find {\n                        eachCard[i][k].tag = eachCard[i][j].tag\n                        eachCard[i][j].tag = -1\n                    }\n                    k += 1\n                }\n            }\n            \/\/for j in 0 ..&lt; 14 {\n            \/\/    if eachCard[i][j].tag &gt;= 0 {\n            \/\/        eachCard[i][j].text = cardObj.disp(card: eachCard[i][j].tag)\n            \/\/    } else {\n            \/\/        eachCard[i][j].text = &quot;\u3000&quot;\n            \/\/    }\n            \/\/}\n        }\n        show()\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u6b21\u56de\u306f\u3001\u30da\u30a2\u524a\u9664\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u3089\u3001\u9078\u629e\u5909\u66f4\u51fa\u6765\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2473\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/xcode15.shimayugu.jp\/?p=829\">\u89e3\u8aac\u7de8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21\u3000\u89e3\u8aac\u7de8 \u3000\u3055\u3066\u3001\u4eca\u56de\u3001\u4eca\u307e\u3067\u3042\u307e\u308a\u306b\u3082\u653e\u7f6e\u3057\u3066\u3044\u305f\u3001\u30dc\u30bf\u30f3\u306e\u8868\u793a\u3092\u4f55\u3068\u304b\u3057\u307e\u3059\u3002 \u3000\u300c\u914d\u5e03\u300d\u30dc\u30bf\u30f3\u3068\u300c\u30da\u30a2\u524a\u9664\u300d\u30dc\u30bf\u30f3\u306b\u3057\u307e\u3057\u305f\u3002\u307e\u305f\u3001Style\u3092Filled\u306b\u3057\u307e\u3057\u305f\u3002\u30dc\u30bf\u30f3\u3092\u9078\u3093\u3067\u3001\u4e00\u756a\u53f3\u306e\u4e0a\u306e\u30a2\u30a4\u30b3\u30f3\u3001\u5de6\u304b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-376","post","type-post","status-publish","format-standard","hentry","category-swift"],"_links":{"self":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=376"}],"version-history":[{"count":7,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/376\/revisions"}],"predecessor-version":[{"id":1032,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/376\/revisions\/1032"}],"wp:attachment":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}