{"id":56,"date":"2024-09-13T11:22:22","date_gmt":"2024-09-13T11:22:22","guid":{"rendered":"https:\/\/xcode15.shimayugu.jp\/?p=56"},"modified":"2024-12-29T06:30:30","modified_gmt":"2024-12-28T21:30:30","slug":"%e6%96%b0swift%e3%81%a7%e8%a1%8c%e3%81%93%e3%81%86%e7%ac%ac%ef%bc%97%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%94","status":"publish","type":"post","link":"https:\/\/xcode15.shimayugu.jp\/?p=56","title":{"rendered":"\u65b0Swift\u3067\u884c\u3053\u3046\u2026\u7b2c\uff17\u56de\u300c\u30cf\u30a4\u30a2\u30f3\u30c9\u30ed\u30fc\u30b2\u30fc\u30e0\uff14\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=517\">\u89e3\u8aac\u7de8<\/a><\/p>\n\n\n\n<p>\u3000\u3055\u3066\u4eca\u5ea6\u306f<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-show-lang=\"1\"><code>        Count.text = &quot;0\u56de\u76ee&quot;\n<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u90e8\u5206\u304c\u3001\u6700\u521d\u306b\u4e00\u56de\u547c\u3070\u308c\u308b\u3060\u3051\u3067\u3042\u308b\u70b9\u3092\u5909\u66f4\u3057\u307e\u3059\u3002\u306a\u305c\u3001\u3053\u308c\u304creset\u306b\u5165\u3063\u3066\u3044\u306a\u3044\u304b\u7591\u554f\u306b\u601d\u308f\u308c\u305f\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n\n\n\n<p>\u3000\u5f53\u305f\u3063\u305f\u6642\u306b\u3001\u6700\u5f8c\u306breset\u3092\u547c\u3093\u3067\u3044\u307e\u3059\u304c\u3001\u5f53\u305f\u308a\u307e\u3057\u305f\u306e\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u305f\u6642\u306b\u3001reset\u95a2\u6570\u3082\u52d5\u4f5c\u3057\u3066\u3057\u307e\u3063\u3066\u3001\u300c\u5927\u304d\u3044\u3067\u3059\u300d\u300c\u5c0f\u3055\u3044\u3067\u3059\u300d\u306e\u8868\u793a\u304c\u300c0~9\u306e\u6570\u5b57\u3092\u5165\u308c\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u4e0b\u3055\u3044\u300d\u306b\u5909\u308f\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u306e\u306b\u6c17\u4ed8\u304b\u308c\u305f\u65b9\u3082\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u3066\u3082\u5f85\u3063\u3066\u3044\u3066\u304f\u308c\u306a\u3044\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3053\u306e\u70b9\u306e\u4fee\u6b63\u3092\u3057\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>        else {\n            let alert = UIAlertController()\n            alert.title = &quot;\u5f53\u305f\u308a&quot;\n            alert.message = &quot;\u5f53\u305f\u308a\u3067\u3059&quot;\n            alert.addAction(UIAlertAction(title: &quot;OK&quot;, style: .default, handler: nil))\n            present(alert, animated: true, completion: nil)\n            reset()\n        }\n<\/code><\/pre><\/div>\n\n\n\n<p>\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4fee\u6b63\u3057\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>        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<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u4ee5\u4e0b\u5168\u4f53\u30bd\u30fc\u30b9\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-line=\"23,37,57-64\" data-show-lang=\"1\"><code>\/\/\n\/\/  ViewController.swift\n\/\/  Hi and Lo\n\/\/\n\/\/  Created by \u4fdd Tabei on 2024\/08\/30.\n\/\/\n\nimport UIKit\n\nclass ViewController: UIViewController {\n\n    @IBOutlet weak var Guide: UILabel!\n    @IBOutlet weak var Input: UITextField!\n    @IBOutlet weak var Count: UILabel!\n    @IBOutlet weak var Level: UISegmentedControl!\n    \n    var randInt:Int = 0\n    var cnt:Int = 0\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \/\/ Do any additional setup after loading the view.\n        \/\/Count.text = &quot;0\u56de\u76ee&quot;\n        reset()\n    }\n    \n    func reset()\n    {\n        if Level.selectedSegmentIndex == 0 {\n            randInt = Int.random(in: 0 ..&lt; 10)\n            Guide.text = &quot;0~9\u306e\u6570\u5b57\u3092\u5165\u308c\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u4e0b\u3055\u3044&quot;\n        } else {\n            randInt = Int.random(in: 0 ..&lt; 20)\n            Guide.text = &quot;0~19\u306e\u6570\u5b57\u3092\u5165\u308c\u3066\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u4e0b\u3055\u3044&quot;\n        }\n        cnt = 0\n        Count.text = &quot;0\u56de\u76ee&quot;\n    }\n\n    @IBAction func LevelChange(_ sender: Any)\n    {\n        reset()\n    }\n    \n\n    @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 &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>\u300023\u884c\u76ee\u306f\u3001\u524a\u9664\u3057\u305f\u306e\u304c\u5206\u304b\u308b\u69d8\u306b\u30b3\u30e1\u30f3\u30c8\u306b\u3057\u307e\u3057\u305f\u3002\u3053\u3053\u306f\u524a\u9664\u3057\u3066\u3057\u307e\u3063\u3066\u3082\u3088\u3044\u3067\u3059\u3002\u300c\/\/\u300d\u3092\u982d\u306b\u4ed8\u3051\u308b\u3068\u30b3\u30e1\u30f3\u30c8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000\u3055\u3066\u554f\u984c\u3067\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>    @IBAction func LevelChange(_ sender: Any)\n    {\n        reset()\n    }\n<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u95a2\u6570\u3092\u5165\u308c\u305f\u306e\u306f\u306a\u305c\u3067\u3057\u3087\u3046\u304b? \u307e\u305f\u3001reset\u95a2\u6570\u306e\u4e2d\u8eab\u3092\u3082\u3046\u5c11\u3057\u30b7\u30f3\u30d7\u30eb\u306b\u51fa\u6765\u306a\u3044\u3067\u3057\u3087\u3046\u304b? \u307e\u305f\u3001\u4eca\u5ea6\u306f\u66f4\u306b\u4e0a\u7d1a(0~29)\u3092\u52a0\u3048\u308b\u3068\u3057\u305f\u3089\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u304b?<\/p>\n\n\n\n<p>\u3000\uff13\u756a\u76ee\u306e\u554f\u984c\u306e\u30d2\u30f3\u30c8\u3067\u3059\u3002\u30bb\u30b0\u30e1\u30f3\u30c6\u30c3\u30c9\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3092\u9078\u3093\u3067\u3001\u53f3\u4e0a\u3001\u5de6\u304b\u3089\uff15\u756a\u76ee\u306e\u30a2\u30a4\u30b3\u30f3\u3092\u9078\u3093\u3067\u3001Segments\u306e\u90e8\u5206\u3092\uff12\u304b\u3089\uff13\u306b\u5909 \u66f4\u3059\u308b\u3068\u3001\uff12\u3064\u533a\u5207\u308a\u3060\u3063\u305f\u3082\u306e\u304c\uff13\u3064\u533a\u5207\u308a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"529\" height=\"670\" src=\"https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/08\/image-9.png\" alt=\"\" class=\"wp-image-62\" srcset=\"https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/08\/image-9.png 529w, https:\/\/xcode15.shimayugu.jp\/wp-content\/uploads\/2024\/08\/image-9-237x300.png 237w\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" \/><\/figure>\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=517\">\u89e3\u8aac\u7de8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21\u3000\u89e3\u8aac\u7de8 \u3000\u3055\u3066\u4eca\u5ea6\u306f \u3053\u306e\u90e8\u5206\u304c\u3001\u6700\u521d\u306b\u4e00\u56de\u547c\u3070\u308c\u308b\u3060\u3051\u3067\u3042\u308b\u70b9\u3092\u5909\u66f4\u3057\u307e\u3059\u3002\u306a\u305c\u3001\u3053\u308c\u304creset\u306b\u5165\u3063\u3066\u3044\u306a\u3044\u304b\u7591\u554f\u306b\u601d\u308f\u308c\u305f\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff1f \u3000\u5f53\u305f\u3063\u305f\u6642\u306b\u3001\u6700\u5f8c\u306breset\u3092\u547c\u3093\u3067\u3044\u307e\u3059\u304c\u3001\u5f53\u305f\u308a\u307e\u3057 [&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-56","post","type-post","status-publish","format-standard","hentry","category-swift"],"_links":{"self":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/56","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=56"}],"version-history":[{"count":14,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":996,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/996"}],"wp:attachment":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}