{"id":84,"date":"2024-09-13T11:24:02","date_gmt":"2024-09-13T11:24:02","guid":{"rendered":"https:\/\/xcode15.shimayugu.jp\/?p=84"},"modified":"2024-12-29T06:32:11","modified_gmt":"2024-12-28T21:32:11","slug":"%e6%96%b0swift%e3%81%a7%e8%a1%8c%e3%81%93%e3%81%86-%e7%ac%ac%ef%bc%99%e5%9b%9e%e3%80%8c%e3%83%8f%e3%82%a4%e3%82%a2%e3%83%b3%e3%83%89%e3%83%ad%e3%83%bc%e3%82%b2%e3%83%bc%e3%83%a0%ef%bc%96%e3%80%8d","status":"publish","type":"post","link":"https:\/\/xcode15.shimayugu.jp\/?p=84","title":{"rendered":"\u65b0Swift\u3067\u884c\u3053\u3046&#8230;\u7b2c\uff19\u56de\u300c\u30cf\u30a4\u30a2\u30f3\u30c9\u30ed\u30fc\u30b2\u30fc\u30e0\uff16\u300d\u3000\u7530\u90e8\u4e95\u4fdd"},"content":{"rendered":"\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2298\"><\/a><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2473\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/xcode15.shimayugu.jp\/?p=538\">\u89e3\u8aac\u7de8<\/a><\/p>\n\n\n\n<p>\u3000\u3055\u3066\u3001\u4eca\u307e\u3067\u7121\u8996\u3057\u3066\u6765\u305f\u306e\u3067\u3059\u304c\u3001TextField\u306b\u4f55\u3082\u5165\u308c\u305a\u306bButton\u3092\u62bc\u3057\u305f\u308a\u3001\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u3092\u5165\u308c\u3066Button\u3092\u62bc\u3059\u3068 \u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-show-lang=\"1\"><code>        let val = Int(Input.text!)!\n<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u3053\u3053\u3067\u3001TextField\u306b\u5165\u3063\u3066\u3044\u308b\u6587\u5b57\u5217\u3092\u7121\u7406\u77e2\u7406\u6570\u5024\u306b\u5909\u3048\u3066\u3044\u308b\u306e\u3067\u3001\u6570\u5024\u4ee5\u5916\u306e\u6587\u5b57\u3084\u7a7a\u767d\u3060\u3068\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u6700\u5f8c\u306e\u201d!\u201d\u3092\u53d6\u308c\u3070\u3001\u305d\u306e\u90e8\u5206\u3067\u306f\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u306f\u3001\u50d5\u306e\u52d8\u9055\u3044\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u3046\u3059\u308b\u3068\u4eca\u5ea6\u306f\u578b\u304c\u4e00\u81f4\u3057\u306a\u3044\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u5b9f\u884c\u51fa\u6765\u306a\u304f\u306a\u308b\u3068\u601d\u3044\u8fbc\u3093\u3067\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u3093\u306a\u4e8b\u306f\u306a\u304b\u3063\u305f\u3067\u3059\u3002\u6700\u521d\u304b\u3089\u201d!\u201d\u3092\u53d6\u3063\u3066\u3044\u308c\u3070\u826f\u304b\u3063\u305f\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3053\u308c\u3092\u53d6\u3063\u3066\u3001\u4f55\u3082\u5165\u308c\u306a\u3044\u3067\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u6642\u3001\u53c8\u306f\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u3092\u5165\u529b\u3057\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u6642\u306b\u5909\u6570val\u306b\u306f\u3001nil\u3068\u3044\u3046\u7279\u5225\u306a\u5024\u304c\u5165\u308a\u307e\u3059\u3002\u305d\u3053\u3067nil\u304b\u3069\u3046\u304b\u5224\u65ad\u3057\u3066\u3001nil\u3060\u3063\u305f\u3089\u300c\u6570\u5024\u3092\u5165\u308c\u3066\u4e0b\u3055\u3044\u300d\u3068\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u7b49\u3057\u3044\u4e8b\u3092\u8868\u3059\u306e\u306b\u300c==\u300d\u3092\u4f7f\u3044\u307e\u3057\u305f\u3002\u6570\u5b66\u3068\u306f\u7570\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u304cC\u8a00\u8a9e\u306e\u6d41\u308c\u3092\u6c72\u3080\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u306f\u3001\u300c=\u300d\u306f\u5909\u6570\u306b\u5024\u3092\u4ee3\u5165\u3059\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u4f7f\u3044\u3001\u7b49\u3057\u3044\u4e8b\u3092\u8868\u3059\u306e\u306b\u306f\u300c==\u300d\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-line=\"4,5-7,8,11\" data-show-lang=\"1\"><code>    @IBAction func TouchBtnGo(_ sender: Any) {\n        cnt = cnt + 1\n        Count.text = cnt.description + &quot;\u56de\u76ee&quot;\n        let val = Int(Input.text!)\n        if val == nil {\n            Guide.text = &quot;\u6570\u5024\u3092\u5165\u308c\u3066\u4e0b\u3055\u3044&quot;\n        }\n        else if val! &gt; randInt {\n            Guide.text = &quot;\u3082\u3063\u3068\u5c0f\u3055\u3044\u3067\u3059&quot;\n        } \n        else if val! &lt; randInt {\n            Guide.text = &quot;\u3082\u3063\u3068\u5927\u304d\u3044\u3067\u3059&quot;\n        } \n        else {\n            Guide.text = &quot;\u5f53\u305f\u308a\u3067\u3059&quot;\n            let okAction = UIAlertAction(title: &quot;OK&quot;, style: .default)\n            { (action) in\n                self.reset()\n            }\n            let alert = UIAlertController(title: &quot;\u5f53\u305f\u308a&quot;, message: &quot;\u5f53\u305f\u308a\u3067\u3059&quot;, preferredStyle: .alert)\n            alert.addAction(okAction)\n            present(alert, animated: true, completion: nil)\n        }\n    }\n<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u3057\u304b\u3057\u3001\u3053\u308c\u3060\u3068\u4f55\u3082\u5165\u308c\u306a\u3044\u3067\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u6642\u3001\u53c8\u306f\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u3092\u5165\u529b\u3057\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u6642\u306b\u30821\u56de\u30ab\u30a6\u30f3\u30c8\u3055\u308c\u3066\u3057\u307e\u3044\u3001\u3042\u307e\u308a\u826f\u304f\u3042\u308a\u307e\u305b\u3093\u3002\u6570\u5024\u4ee5\u5916\u3092\u5165\u308c\u305f\u6642\u306f\u3001\u6570\u5024\u3092\u3044\u308c\u308b\u3088\u3046\u306b\u4fc3\u3057\u3001\u30ab\u30a6\u30f3\u30c8\u3057\u306a\u3044\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u305d\u3053\u3067\u30ab\u30a6\u30f3\u30c8\u90e8\u5206\u3092\u79fb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3067\u5927\u5206\u826f\u304f\u306a\u3063\u305f\u3068\u601d\u3044\u307e\u3059\u3002 \u4ee5\u4e0b\u554f\u984c\u306e\u90e8\u5206\u306e\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=\"6-25\" data-show-lang=\"1\"><code>    @IBAction func TouchBtnGo(_ sender: Any) {\n        let val = Int(Input.text!)\n        if val == nil {\n            Guide.text = &quot;\u6570\u5024\u3092\u5165\u308c\u3066\u4e0b\u3055\u3044&quot;\n        }\n        else {\n            cnt = cnt + 1\n            Count.text = cnt.description + &quot;\u56de\u76ee&quot;\n            if val! &gt; randInt {\n                Guide.text = &quot;\u3082\u3063\u3068\u5c0f\u3055\u3044\u3067\u3059&quot;\n            }\n            else if val! &lt; randInt {\n                Guide.text = &quot;\u3082\u3063\u3068\u5927\u304d\u3044\u3067\u3059&quot;\n            }\n            else {\n                Guide.text = &quot;\u5f53\u305f\u308a\u3067\u3059&quot;\n                let okAction = UIAlertAction(title: &quot;OK&quot;, style: .default)\n                { (action) in\n                    self.reset()\n                }\n                let alert = UIAlertController(title: &quot;\u5f53\u305f\u308a&quot;, message: &quot;\u5f53\u305f\u308a\u3067\u3059&quot;, preferredStyle: .alert)\n                alert.addAction(okAction)\n                present(alert, animated: true, completion: nil)\n            }\n        }\n    }\n<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u3055\u3066\u3001\u3053\u3053\u3067\u4e00\u65e6\u3001\u30cf\u30a4\u30a2\u30f3\u30c9\u30ed\u30fc\u30b2\u30fc\u30e0\u306f\u7d42\u4e86\u3057\u307e\u3059\u3002\u3084\u308d\u3046\u3068\u601d\u3048\u3070\u3001\uff13\u56de\u30b2\u30fc\u30e0\u3092\u3057\u3066\u304b\u304b\u3063\u305f\u56de\u6570\u306e\u5408\u8a08\u3092\u51fa\u3057\u3001\u305d\u308c\u306e\u4e00\u756a\u5c0f\u3055\u306a\u5024\u3092\u4fdd\u6301\u3057\u3066\u304a\u304d\u3001\u6700\u77ed\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u8a18\u9332\u3092\u6b8b\u3059\u3002\u307e\u305f\u306f\u3001\uff13\u56de\u7f6e\u304d\u306b\u5618\u3092\u3064\u3044\u3066(\u672c\u5f53\u306f\u5c0f\u3055\u3044\u306e\u306b\u5927\u304d\u3044\u3067\u3059\u3068\u51fa\u3059\u3002\u5927\u304d\u3044\u6642\u3082\u540c\u69d8\u3002\u5f53\u305f\u3063\u305f\u6642\u3060\u3051\u306f\u5f53\u305f\u308a\u3068\u3059\u308b)\u3001\u305d\u308c\u304c\u6700\u521d\u304b\u3089\u306a\u306e\u304b\u3001\uff12\u56de\u76ee\u304b\u3089\u306a\u306e\u304b\u3001\uff13\u56de\u76ee\u304b\u3089\u306a\u306e\u304b\u304c\u5224\u3089\u306a\u3044\u306e\u3067\u3001\u30b2\u30fc\u30e0\u306e\u96e3\u6613\u5ea6\u304c\u4e0a\u304c\u308b\u3068\u3044\u3046\u30b2\u30fc\u30e0\u306b\u3059\u308b\u7b49\u3001\u30a2\u30a4\u30c7\u30a2\u6b21\u7b2c\u3067\u8272\u3005\u51fa\u6765\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u6700\u521d\u306e\u8a18\u9332\u4fdd\u6301\u306f\u4eca\u306e\u77e5\u8b58\u3067\u306f\u96e3\u3057\u3044\u3067\u3059\u304c\u3001\uff13\u56de\u7f6e\u304d\u306b\u5618\u3092\u3064\u304f\u307b\u3046\u306f\u3001\u4f55\u3068\u304b\u51fa\u6765\u308b\u304b\u3082\u77e5\u308c\u307e\u305b\u3093(\u5909\u6570\u306e\u6271\u3044\u304c\u307e\u3060\u96e3\u3057\u3044\u304b\u306a)\u3002<\/p>\n\n\n\n<p>\u3000\u3044\u305a\u308c\u306b\u305b\u3088\u3001\u6b21\u56de\u306f\u96fb\u5b50\u30b5\u30a4\u30b3\u30ed\u3001\u305d\u3057\u3066\u305d\u306e\u6b21\u304b\u3089\u30c8\u30e9\u30f3\u30d7\u306b\u5165\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u307e\u305a\u96fb\u5b50\u30b5\u30a4\u30b3\u30ed\u3067\u3059\u304c\u3001\u30cf\u30a4\u30a2\u30f3\u30c9\u30ed\u30fc\u30b2\u30fc\u30e0\u306e\u77e5\u8b58\u304c\u3042\u308c\u3070\u4f5c\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u305f\u3060\u5358\u306b\uff11\u301c\uff16\u306e\u6570\u5024\u3092\u51fa\u3059\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002\u7686\u3055\u3093\u3001\u4f5c\u3063\u3066\u307f\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2298\"><\/a><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2473\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/xcode15.shimayugu.jp\/?p=538\">\u89e3\u8aac\u7de8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21\u3000\u89e3\u8aac\u7de8 \u3000\u3055\u3066\u3001\u4eca\u307e\u3067\u7121\u8996\u3057\u3066\u6765\u305f\u306e\u3067\u3059\u304c\u3001TextField\u306b\u4f55\u3082\u5165\u308c\u305a\u306bButton\u3092\u62bc\u3057\u305f\u308a\u3001\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u3092\u5165\u308c\u3066Button\u3092\u62bc\u3059\u3068 \u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002 \u3000\u3053\u3053\u3067\u3001TextField\u306b\u5165\u3063\u3066\u3044\u308b\u6587\u5b57\u5217\u3092\u7121 [&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-84","post","type-post","status-publish","format-standard","hentry","category-swift"],"_links":{"self":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/84","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=84"}],"version-history":[{"count":8,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}