Rails 開発-1 Bootstrapの導入

application.html.erb

BootstrapとJavaScriptを読み込み

Bootstrap本家サイト GitHub - twbs/bootstrap-rubygem: Bootstrap 4 rubygem for Rails / Sprockets / Hanami / etc

gemはこんな感じ

gem 'bootstrap', '~> 4.0.0'
gem 'mini_racer'
gem 'autoprefixer-rails', '~> 9.3', '>= 9.3.1'
gem 'sprockets-rails'
gem 'jquery-rails'

app/assets/stylesheets/application.scss

に書き加える。cssファイルしなかに場合は、scssにリネイムする。

@import "bootstrap";

を加えて = require and = require_treeは削除 Bootstrapを利用できなくなるので

application.jsに下記を追加

//= require jquery3
//= require popper
//= require bootstrap-sprockets

ここでBootstrapがきいているかチェック 画面がおかしかったの

app>asset.stylesheetの中におかしなファイルができていた

application.css

application.css.map

これを削除すると、画面がもとに戻る。 Bootstrapも効いている。

でエラー f:id:happy_teeth_ago:20181128104635p:plain

config/initializers/assets.rb に読み込むcssを記載 ディレクトリごと読み込みたい場合は

config.assets.precompile += ['directory/*']

config>initializer>asset.rb

Rails.application.config.assets.precompile += ['clients/*']

f:id:happy_teeth_ago:20181128114605p:plain Bootstrapも効きました。

しかしrequire rails-ujsが2回呼ばれるエラー

f:id:happy_teeth_ago:20181128144042p:plain

画面のファイルの

//= require rails-ujs

を削除すると呼ばれなくなった。 bootstrapとかぶっているgemのようだ。

めでたし、めでたし

Rails 日付を日本語表示にする。 strftimeメソッド

f:id:happy_teeth_ago:20181119070203p:plain このように表示されてしまう。

これを日本語表記で表示したい。

strftimeメソッドを利用する。

Rubyの組み込みオブジェクト

strftime(フォーマット引数)

これだけ

<%= datperson.updated_at.strftime('%Y年%m月%d日 %H時%M分')  %>

f:id:happy_teeth_ago:20181119070649p:plain

config>initializer>time_formats.rbファイルを作成。

そこに記載しておく そうするとどのファイルからでも、引数でとってこれる。

引数はdatetime_jp

#Time型のDATE_FORMATSに[:datetime_jp]のキーでフォーマットを設定している = '%Y年'
Time::DATE_FORMATS[:datetime_jp] = '%Y年%m月%d日 %H時 %M分'

めでたしめでたし。

参考資料 ビュー(view) - - Railsドキュメント

Swift getter setterの処理-セッターゲッターとは

ゲッター、セッターとはそもそも何か?

コンピューテッドプロパティといって、値を保持せずに、算出するプロパティのこと。

??となるので、まずコードを参照。

コンピューテッドプロパティの定義はこのように記載

var プロパティ名:型名{
get{
      値を返す処理
    }
set{
    値を更新する処理
    代入された値にはnewValueとしてアクセス可能
    }
}

実際に書いてみる

class Item {

    // 税抜き価格
    var price:Double = 0

    // 税込み価格
    var intaxPrice:Double {

        // 値を取得するときに呼ばれる。
        get{
            return self.price*1.08
        }

        // 値がセットされるときに呼ばれる。
        set{
            price = newValue/1.08
        }
    }

}

これを実行するとこうなる。

var item = Item()

item.intaxPrice = 108.0

//intaxPriceはコンピューテッドプロパティで値を持たない、算出する

//よってここでは、itemに100がセットされる

print(item.price)
//100になっている

item.price = 150
//今度はpriceに値150をセット

print(item.intaxPrice)
//162になっている

//intaxPriceには何も変更を加えていないのに、162になる

//これが値を保持せずに、値を算出するということ

参考サイト 【Swift】セッター(Setter)、ゲッター(Getter)の処理を書く - Qiita

これができたから何?となると思います。

それで、実際に利用したソースを示します。

画面を越えて、値を状態を保持したいときなどに、利用します。

プロトコルを宣言して、そのプロトコルにゲッター、セッターを定義しておけば、そのプロトコルを利用したクラスでは、このゲッターセッターが利用できます。 左画面から右画面へテーブルビューへ表示する、配列を渡したいとします。 別Viewになっていますので、そのままでは値を渡せません。 ここで登場するのが、先程のゲッターセッター、そしてプロトコルです。 f:id:happy_teeth_ago:20181118202846p:plain

まずプロトコルの宣言 どこに記載しても良いです。

protocol wordDelegate {
   
 var ofDics:[DatDic]?{get set}

}

ofDics という変数名で型は DatDic型の配列になっています。

そして{ }でゲッターセッターが宣言されています。 一つの値を変更すれば、もう片方に値がセットされると言うことです。

目的は左画面のtableViewに表示され、タッチしたところから下にあるものすべての配列を、右画面に渡します。

では、左画面のソースを見てみましょう。

 //デリゲートのインスタンス
    var ofWord: wordDelegate?

//テーブルをタッチしたときの処理
   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        //配列の特定の行から最後までをdetailDicへ移動する

        ofWord?.ofDics = Array(datDics![indexPath.row..<datDics!.endIndex])

//ここでofWordを利用して、プロトコルのプロパティにアクセスしています。

//別の画面のプロパティになります。        

    }

では遷移先、右画面では、どのように記載するのでしょうか?

    var ofDics: [DatDic]?{

        set{//set newvalu=左でsetした値が入る

            datDics = newValue

            tableView.reloadData()

//左でセットした値が入る。それでtableをリロードする。

        }

        get{//setしたdatDicsを表示しているだけ

            return datDics

        }

    }

//メンバ変数 ゲッターで帰ってきた値が詰め込まれるため。   

    var datDics:[DatDic]?

あとはTableViewにdatDicsを表示するだけ。 左から右に値を渡せました。

swift git ignore Mac 特殊ファイルの除外追加

MAC独特の特殊ファイルの除外を追加 それだけです。

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Mac File System specific files
.DS_Store

## Build generatedビルドファイルは無視
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

Swift XMLParserでCDATAをparseをする !編集途中読まないこと!

まずCDATAとは

 XMLはマークアップ言語であるため、XML文書を記述する際には、マークアップ用として指定された記号を直接文字として記述することができない。これを記述してもマークアップの指定と解釈され、文字として解釈されないためである。 しかし、マークアップ専用の記号であって、通常の文字として扱う特例的な部分をつくることができる。これを、CDATAセクションという。

CDATAセクションは、<![CDATA[という文字列で始まり、]]>という文字列で終わる。

CDATAセクションの中にはHTMLタグも埋め込むことができるので、RSSを配信している側にとっては便利。

でもXMLパーサーを回避するので、XML解析する側にとっては嫌な存在です。 ただ、XMLParserにはCDATAを解析するメソッドが用意されている。

引用 XML用語事典 [CDATAセクション]

(初心者向け)NSXMLParserでCDATAを解析する - Qiita

中身はbitコード。

ちなみにエンドポイントはこんなかんじ。

<?xml version="1.0" encoding="UTF-8"?><![CDATA[Apple Newsroom]]><![CDATAhttps://www.apple.com/jp/newsroom/]><![CDATA[2018-11-02T02:11:47.085Z]]><![CDATA[2018-11-02T02:11:47.085Z]]><![CDATA[Apple縲∫ャャ4蝗帛濠譛溘�讌ュ邵セ逋コ陦ィ]]><![CDATAhttps://www.apple.com/jp/newsroom/2018/11/apple-reports-fourth-quarter-results/]><![CDATA[Apple Newsroom]]><![CDATA[Apple縲∫ャャ4蝗帛濠譛溘�讌ュ邵セ逋コ陦ィ
螢イ荳企ォ倥′20��い繝��縲・PS縺ッ41��い繝��縺ィ縲�7縲�9譛域悄縺ョ譁ー險倬鹸繧帝#謌�

この中からtitleとid(リンク先)を取得したい。

まず普通にparseを始める。

    func startDownload() {
        self.items = []
        if let url = URL(
            string: "http://www.apple.com/jp/pr/feeds/pr.rss"){
            //インスタンスの生成
            if let parser = XMLParser(contentsOf: url) {
                self.parser = parser
                self.parser.delegate = self
    //これにより下記メソッドが呼ばれる
                self.parser.parse()
            }
        }
    }

ここで3つのメソッドがポイント

一つは、要素の開始ごとに呼ばれるメソッド

もう一つは、CDATAごとに呼ばれるメソッド

もう一つは、要素の終了ごとに呼ばれるメソッド

     //要素の開始タグごとに呼ばれる
    func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String])

// CDATAを見つけるごとに呼ばれる エンコードする必要があり
    func parser(_ parser: XMLParser, foundCDATA CDATABlock: Data) {

   //要素の終了ごとに呼ばれるメソッド
    func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {

エンドポイントを見ると、要素の開始タグの次にCDATAが来て、タイトルが入っている。そこで読み込みをしたい。 そのために読み込むかどうかを判断するbool型を宣言しておく。</p> <pre class="code lang-swift" data-lang="swift" data-unlink> <span class="synPreProc">var</span> <span class="synIdentifier">readOrNot</span><span class="synSpecial">:</span><span class="synType">Bool</span> <span class="synIdentifier">=</span> <span class="synConstant">false</span> <span class="synComment">//他のメンバ変数</span> <span class="synPreProc">var</span> <span class="synIdentifier">parser</span><span class="synSpecial">:</span><span class="synType">XMLParser</span><span class="synIdentifier">!</span> <span class="synPreProc">var</span> <span class="synIdentifier">items</span> <span class="synIdentifier">=</span> [Item]() <span class="synPreProc">var</span> <span class="synIdentifier">item</span><span class="synSpecial">:</span><span class="synType">Item</span>? <span class="synPreProc">var</span> <span class="synIdentifier">currentString</span><span class="synSpecial">:</span><span class="synType">String</span>? </pre> <p>これにより、CDATA部分で読み込むかどうかを判断させる方針とする。</p> <h4>これは上記要素の開始ごとに呼ばれるメソッドに記載する。</h4> <p>それによりCDATAの読み込み時に切り分けをする。 すべてのタグを読み込んだら大変なことになる。</p> <pre class="code" data-lang="" data-unlink> if elementName == "title" || elementName == "id" { readOrNot = true</pre> </div> <footer class="entry-footer"> <div class="entry-tags-wrapper"> <div class="entry-tags"> </div> </div> <p class="entry-footer-section track-inview-by-gtm" data-gtm-track-json="{"area": "finish_reading"}"> <span class="author vcard"><span class="fn" data-load-nickname="1" data-user-name="happy_teeth_ago" >happy_teeth_ago</span></span> <span class="entry-footer-time"><a href="https://happy-teeth.hatenablog.com/entry/2018/11/07/084951"><time data-relative datetime="2018-11-06T23:49:51Z" title="2018-11-06T23:49:51Z" class="updated">2018-11-07 08:49</time></a></span> <span class=" entry-footer-subscribe " data-test-blog-controlls-subscribe> <a href="https://blog.hatena.ne.jp/happy_teeth_ago/happy-teeth.hatenablog.com/subscribe?utm_medium=button&utm_campaign=subscribe_blog&utm_source=blogs_entry_footer"> 読者になる </a> </span> </p> <div class="hatena-star-container" data-hatena-star-container data-hatena-star-url="https://happy-teeth.hatenablog.com/entry/2018/11/07/084951" data-hatena-star-title="Swift XMLParserでCDATAをparseをする !編集途中読まないこと!" data-hatena-star-variant="profile-icon" data-hatena-star-profile-url-template="https://blog.hatena.ne.jp/{username}/" ></div> <div class="social-buttons"> <div class="social-button-item"> <a href="https://b.hatena.ne.jp/entry/s/happy-teeth.hatenablog.com/entry/2018/11/07/084951" class="hatena-bookmark-button" data-hatena-bookmark-url="https://happy-teeth.hatenablog.com/entry/2018/11/07/084951" data-hatena-bookmark-layout="vertical-balloon" data-hatena-bookmark-lang="ja" title="この記事をはてなブックマークに追加"><img src="https://b.st-hatena.com/images/entry-button/button-only.gif" alt="この記事をはてなブックマークに追加" width="20" height="20" style="border: none;" /></a> </div> <div class="social-button-item"> <div class="fb-share-button" data-layout="box_count" data-href="https://happy-teeth.hatenablog.com/entry/2018/11/07/084951"></div> </div> <div class="social-button-item"> <a class="entry-share-button entry-share-button-twitter test-share-button-twitter" href="https://twitter.com/intent/tweet?text=Swift+XMLParser%E3%81%A7CDATA%E3%82%92parse%E3%82%92%E3%81%99%E3%82%8B+!%E7%B7%A8%E9%9B%86%E9%80%94%E4%B8%AD%E8%AA%AD%E3%81%BE%E3%81%AA%E3%81%84%E3%81%93%E3%81%A8!+-+happy_teeth's+%E5%BF%98%E5%82%99%E9%8C%B2&url=https%3A%2F%2Fhappy-teeth.hatenablog.com%2Fentry%2F2018%2F11%2F07%2F084951" title="X(Twitter)で投稿する" ></a> </div> <span> <div class="line-it-button" style="display: none;" data-type="share-e" data-lang="ja" ></div> <script src="//scdn.line-apps.com/n/line_it/thirdparty/loader.min.js" async="async" defer="defer" ></script> </span> </div> <div class="google-afc-image test-google-rectangle-ads"> <script> (valve = window.valve || []).push(function(v) { v.displayDFPSlot('google_afc_user_container_5'); }); </script> <div id="google_afc_user_container_5" class="google-afc-user-container google_afc_blocklink2_5 google_afc_boder" data-test-unit="/4374287/blog_user_2nd"></div> <a href="http://blog.hatena.ne.jp/guide/pro" class="open-pro-modal" data-guide-pro-modal-ad-url="https://hatena.blog/guide/pro/modal/ad">広告を非表示にする</a> </div> <div class="customized-footer"> </div> <div class="comment-box js-comment-box"> <ul class="comment js-comment"> <li class="read-more-comments" style="display: none;"><a>もっと読む</a></li> </ul> <a class="leave-comment-title js-leave-comment-title">コメントを書く</a> </div> </footer> </div> </article> <article class="entry hentry test-hentry js-entry-article date-first autopagerize_page_element chars-200 words-100 mode-markdown entry-even" id="entry-10257846132663203835" data-keyword-campaign="" data-uuid="10257846132663203835" data-publication-type="entry"> <div class="entry-inner"> <header class="entry-header"> <div class="date entry-date first"> <a href="https://happy-teeth.hatenablog.com/archive/2018/11/01" rel="nofollow"> <time datetime="2018-11-01T12:53:17Z" title="2018-11-01T12:53:17Z"> <span class="date-year">2018</span><span class="hyphen">-</span><span class="date-month">11</span><span class="hyphen">-</span><span class="date-day">01</span> </time> </a> </div> <h1 class="entry-title"> <a href="https://happy-teeth.hatenablog.com/entry/2018/11/01/215317" class="entry-title-link bookmark">Swift TabBarでの値の受け渡し</a> </h1> </header> <div class="entry-content hatenablog-entry"> <p>TabbarControllerでの値の受け渡しの記事がなかったのでまとめておきます。</p> </div> <footer class="entry-footer"> <div class="entry-tags-wrapper"> <div class="entry-tags"> </div> </div> <p class="entry-footer-section track-inview-by-gtm" data-gtm-track-json="{"area": "finish_reading"}"> <span class="author vcard"><span class="fn" data-load-nickname="1" data-user-name="happy_teeth_ago" >happy_teeth_ago</span></span> <span class="entry-footer-time"><a href="https://happy-teeth.hatenablog.com/entry/2018/11/01/215317"><time data-relative datetime="2018-11-01T12:53:17Z" title="2018-11-01T12:53:17Z" class="updated">2018-11-01 21:53</time></a></span> <span class=" entry-footer-subscribe " data-test-blog-controlls-subscribe> <a href="https://blog.hatena.ne.jp/happy_teeth_ago/happy-teeth.hatenablog.com/subscribe?utm_source=blogs_entry_footer&utm_campaign=subscribe_blog&utm_medium=button"> 読者になる </a> </span> </p> <div class="hatena-star-container" data-hatena-star-container data-hatena-star-url="https://happy-teeth.hatenablog.com/entry/2018/11/01/215317" data-hatena-star-title="Swift TabBarでの値の受け渡し" data-hatena-star-variant="profile-icon" data-hatena-star-profile-url-template="https://blog.hatena.ne.jp/{username}/" ></div> <div class="social-buttons"> <div class="social-button-item"> <a href="https://b.hatena.ne.jp/entry/s/happy-teeth.hatenablog.com/entry/2018/11/01/215317" class="hatena-bookmark-button" data-hatena-bookmark-url="https://happy-teeth.hatenablog.com/entry/2018/11/01/215317" data-hatena-bookmark-layout="vertical-balloon" data-hatena-bookmark-lang="ja" title="この記事をはてなブックマークに追加"><img src="https://b.st-hatena.com/images/entry-button/button-only.gif" alt="この記事をはてなブックマークに追加" width="20" height="20" style="border: none;" /></a> </div> <div class="social-button-item"> <div class="fb-share-button" data-layout="box_count" data-href="https://happy-teeth.hatenablog.com/entry/2018/11/01/215317"></div> </div> <div class="social-button-item"> <a class="entry-share-button entry-share-button-twitter test-share-button-twitter" href="https://twitter.com/intent/tweet?text=Swift+TabBar%E3%81%A7%E3%81%AE%E5%80%A4%E3%81%AE%E5%8F%97%E3%81%91%E6%B8%A1%E3%81%97+-+happy_teeth's+%E5%BF%98%E5%82%99%E9%8C%B2&url=https%3A%2F%2Fhappy-teeth.hatenablog.com%2Fentry%2F2018%2F11%2F01%2F215317" title="X(Twitter)で投稿する" ></a> </div> <span> <div class="line-it-button" style="display: none;" data-type="share-e" data-lang="ja" ></div> <script src="//scdn.line-apps.com/n/line_it/thirdparty/loader.min.js" async="async" defer="defer" ></script> </span> </div> <div class="google-afc-image test-google-rectangle-ads"> <script> (valve = window.valve || []).push(function(v) { v.displayDFPSlot('google_afc_user_container_6'); }); </script> <div id="google_afc_user_container_6" class="google-afc-user-container google_afc_blocklink2_5 google_afc_boder" data-test-unit="/4374287/blog_user_2nd"></div> <a href="http://blog.hatena.ne.jp/guide/pro" class="open-pro-modal" data-guide-pro-modal-ad-url="https://hatena.blog/guide/pro/modal/ad">広告を非表示にする</a> </div> <div class="customized-footer"> </div> <div class="comment-box js-comment-box"> <ul class="comment js-comment"> <li class="read-more-comments" style="display: none;"><a>もっと読む</a></li> </ul> <a class="leave-comment-title js-leave-comment-title">コメントを書く</a> </div> </footer> </div> </article> <article class="entry hentry test-hentry js-entry-article date-first autopagerize_page_element chars-2800 words-400 mode-markdown entry-odd" id="entry-10257846132661450311" data-keyword-campaign="" data-uuid="10257846132661450311" data-publication-type="entry"> <div class="entry-inner"> <header class="entry-header"> <div class="date entry-date first"> <a href="https://happy-teeth.hatenablog.com/archive/2018/10/29" rel="nofollow"> <time datetime="2018-10-29T09:52:25Z" title="2018-10-29T09:52:25Z"> <span class="date-year">2018</span><span class="hyphen">-</span><span class="date-month">10</span><span class="hyphen">-</span><span class="date-day">29</span> </time> </a> </div> <h1 class="entry-title"> <a href="https://happy-teeth.hatenablog.com/entry/2018/10/29/185225" class="entry-title-link bookmark">Swift Geocode googlemap からappleの関数へ変更</a> </h1> </header> <div class="entry-content hatenablog-entry"> <p>このソースが動かなくなった</p> <pre class="code lang-swift" data-lang="swift" data-unlink> <span class="synComment">/// 住所ボタン=住所の位置を登録して、登録した位置を中央に表示してピンを落とす。</span> <span class="synType">@IBAction</span> <span class="synPreProc">func</span> <span class="synIdentifier">centerLocationFromAddress</span>(_ sender<span class="synSpecial">:</span> <span class="synType">Any</span>) { <span class="synComment">//住所のnilチェック</span> <span class="synStatement">guard</span> <span class="synPreProc">let</span> <span class="synIdentifier">addr</span> <span class="synIdentifier">=</span> uiJusho.text, <span class="synIdentifier">!</span>addr.isEmpty <span class="synStatement">else</span> { <span class="synStatement">return</span> } <span class="synComment">//Google geolocation関数呼び出し、ここが2018.2よりGoogleの仕様変更で利用できない</span> <span class="synComment">//軽度緯度をAPIで取得しているだけ 下記に示す</span> <span class="synStatement">guard</span> <span class="synPreProc">let</span> <span class="synIdentifier">location</span> <span class="synIdentifier">=</span> GmsUtils.getLocationOf(addr) <span class="synStatement">else</span> { MsAlert.confirmOk(<span class="synIdentifier">self</span>,<span class="synConstant">"MsgMapGmsGeocodeNoResponse"</span>) <span class="synStatement">return</span> } <span class="synComment">//返却された、経度、緯度をMAPの中心に表示する関数を呼び出し</span> msMapAgent?.center(point<span class="synSpecial">:</span><span class="synType">location</span>, animated<span class="synSpecial">:</span><span class="synType">true</span>) registarPersonLocation(location) <span class="synComment">//キーボードを閉じる</span> textUiPlaceAdjuster.endEditing() } </pre> <h2>getLocationOf(addr)</h2> <pre class="code lang-swift" data-lang="swift" data-unlink> <span class="synComment">/// 住所の位置を検索し返す</span> <span class="synPreProc">static</span> <span class="synPreProc">func</span> <span class="synIdentifier">getLocationOf</span>(_ address<span class="synSpecial">:</span> <span class="synType">String</span>) <span class="synSpecial">-></span> <span class="synType">CLLocationCoordinate2D</span>? { <span class="synComment">// address は query部分に当たるので所定のエンコードを行う</span> <span class="synStatement">guard</span> <span class="synPreProc">let</span> <span class="synIdentifier">encAddr</span> <span class="synIdentifier">=</span> address.addingPercentEncoding( withAllowedCharacters<span class="synSpecial">:</span> <span class="synType">NSCharacterSet.urlQueryAllowed</span>), <span class="synIdentifier">!</span>encAddr.isEmpty <span class="synStatement">else</span> { <span class="synStatement">return</span> <span class="synConstant">nil</span> } <span class="synComment">// goole geocode サービス要求:dataが返されない事もありうる。</span> <span class="synPreProc">let</span> <span class="synIdentifier">strUrl</span> <span class="synIdentifier">=</span> <span class="synConstant">"https://maps.google.com/maps/api/geocode/json?address=</span><span class="synSpecial">\(encAddr)</span><span class="synConstant">&sensor=false"</span> <span class="synStatement">guard</span> <span class="synPreProc">let</span> <span class="synIdentifier">url</span> <span class="synIdentifier">=</span> URL(string<span class="synSpecial">:</span> <span class="synType">strUrl</span>), <span class="synPreProc">let</span> <span class="synIdentifier">data</span> <span class="synIdentifier">=</span> try? Data(contentsOf<span class="synSpecial">:</span> <span class="synType">url</span>) <span class="synStatement">else</span> { <span class="synStatement">return</span> <span class="synConstant">nil</span> } <span class="synComment">//JSONSerializationにて解析</span> <span class="synComment">// 結果を解析</span> <span class="synStatement">guard</span> <span class="synPreProc">let</span> <span class="synIdentifier">json</span> <span class="synIdentifier">=</span> try? JSONSerialization.jsonObject(with<span class="synSpecial">:</span> <span class="synType">data</span>, options<span class="synSpecial">:</span> <span class="synType">JSONSerialization.ReadingOptions.allowFragments</span>) <span class="synStatement">as</span><span class="synIdentifier">!</span> NSDictionary, (json[<span class="synConstant">"status"</span>] <span class="synStatement">as</span>? String) <span class="synIdentifier">==</span> <span class="synConstant">"OK"</span> <span class="synStatement">else</span> { <span class="synStatement">return</span> <span class="synConstant">nil</span> } <span class="synStatement">guard</span> <span class="synPreProc">let</span> <span class="synIdentifier">result</span> <span class="synIdentifier">=</span> json[<span class="synConstant">"results"</span>] <span class="synStatement">as</span>? NSArray, result.count <span class="synIdentifier">></span> <span class="synConstant">0</span>, <span class="synPreProc">let</span> <span class="synIdentifier">geometry</span> <span class="synIdentifier">=</span> (result[<span class="synConstant">0</span>] <span class="synStatement">as</span><span class="synIdentifier">!</span> NSDictionary)[<span class="synConstant">"geometry"</span>] <span class="synStatement">as</span>? NSDictionary, <span class="synPreProc">let</span> <span class="synIdentifier">location</span> <span class="synIdentifier">=</span> geometry[<span class="synConstant">"location"</span>] <span class="synStatement">as</span>? NSDictionary, <span class="synPreProc">let</span> <span class="synIdentifier">lat</span> <span class="synIdentifier">=</span> location[<span class="synConstant">"lat"</span>] <span class="synStatement">as</span>? Double, <span class="synPreProc">let</span> <span class="synIdentifier">lng</span> <span class="synIdentifier">=</span> location[<span class="synConstant">"lng"</span>] <span class="synStatement">as</span>? Double <span class="synStatement">else</span> { <span class="synComment">//print("\n\(lat), \(lng)")</span> <span class="synStatement">return</span> <span class="synConstant">nil</span> } <span class="synComment">// ここで返却している CLLocationDegrees型で</span> <span class="synComment">//init(latitude: CLLocationDegrees, longitude: CLLocationDegrees)</span> <span class="synStatement">return</span> CLLocationCoordinate2D(latitude<span class="synSpecial">:</span> <span class="synType">lat</span>, longitude<span class="synSpecial">:</span> <span class="synType">lng</span>) } </pre> <p>Appleの関数のみでの実装</p> <pre class="code" data-lang="" data-unlink> /// 検査ボタン押下 func searchBarSearchButtonClicked(_ searchBar: UISearchBar){ // キーボードを納め、探す場所が入力されていれば、それを探す self.view.endEditing(true) guard let adress = uiSearchLocation.text, !adress.isEmpty else { return } // 検索は非同期で、時間がかかることもあるのでキャンセルボタンを表示し // 結果が返されるまでの間でキャンセル可能とする searchBar.showsCancelButton = true CLGeocoder().geocodeAddressString( adress, completionHandler:geocodeComplete) }</pre> <pre class="code" data-lang="" data-unlink> func geocodeComplete(places:[CLPlacemark]?, error:Error?) { self.uiSearchLocation.showsCancelButton = false if error != nil { // localizedDescription には次のような文字列が入っていた // The operation couldn’t be completed. (kCLErrorDomain error 8.) // そのまま出すとオペレータの混乱を招くので MagMsgGmsGeocodeNoResponse // を使う MsAlert.confirmOk(self,"MagMsgGmsGeocodeNoResponse") return } if let _places = places, !_places.isEmpty { if let ll = _places[0].location?.coordinate { self.msMapAgent.center(point:ll, animated:true) } } }</pre> </div> <footer class="entry-footer"> <div class="entry-tags-wrapper"> <div class="entry-tags"> </div> </div> <p class="entry-footer-section track-inview-by-gtm" data-gtm-track-json="{"area": "finish_reading"}"> <span class="author vcard"><span class="fn" data-load-nickname="1" data-user-name="happy_teeth_ago" >happy_teeth_ago</span></span> <span class="entry-footer-time"><a href="https://happy-teeth.hatenablog.com/entry/2018/10/29/185225"><time data-relative datetime="2018-10-29T09:52:25Z" title="2018-10-29T09:52:25Z" class="updated">2018-10-29 18:52</time></a></span> <span class=" entry-footer-subscribe " data-test-blog-controlls-subscribe> <a href="https://blog.hatena.ne.jp/happy_teeth_ago/happy-teeth.hatenablog.com/subscribe?utm_medium=button&utm_source=blogs_entry_footer&utm_campaign=subscribe_blog"> 読者になる </a> </span> </p> <div class="hatena-star-container" data-hatena-star-container data-hatena-star-url="https://happy-teeth.hatenablog.com/entry/2018/10/29/185225" data-hatena-star-title="Swift Geocode googlemap からappleの関数へ変更" data-hatena-star-variant="profile-icon" data-hatena-star-profile-url-template="https://blog.hatena.ne.jp/{username}/" ></div> <div class="social-buttons"> <div class="social-button-item"> <a href="https://b.hatena.ne.jp/entry/s/happy-teeth.hatenablog.com/entry/2018/10/29/185225" class="hatena-bookmark-button" data-hatena-bookmark-url="https://happy-teeth.hatenablog.com/entry/2018/10/29/185225" data-hatena-bookmark-layout="vertical-balloon" data-hatena-bookmark-lang="ja" title="この記事をはてなブックマークに追加"><img src="https://b.st-hatena.com/images/entry-button/button-only.gif" alt="この記事をはてなブックマークに追加" width="20" height="20" style="border: none;" /></a> </div> <div class="social-button-item"> <div class="fb-share-button" data-layout="box_count" data-href="https://happy-teeth.hatenablog.com/entry/2018/10/29/185225"></div> </div> <div class="social-button-item"> <a class="entry-share-button entry-share-button-twitter test-share-button-twitter" href="https://twitter.com/intent/tweet?text=Swift+Geocode+googlemap+%E3%81%8B%E3%82%89apple%E3%81%AE%E9%96%A2%E6%95%B0%E3%81%B8%E5%A4%89%E6%9B%B4+-+happy_teeth's+%E5%BF%98%E5%82%99%E9%8C%B2&url=https%3A%2F%2Fhappy-teeth.hatenablog.com%2Fentry%2F2018%2F10%2F29%2F185225" title="X(Twitter)で投稿する" ></a> </div> <span> <div class="line-it-button" style="display: none;" data-type="share-e" data-lang="ja" ></div> <script src="//scdn.line-apps.com/n/line_it/thirdparty/loader.min.js" async="async" defer="defer" ></script> </span> </div> <div class="google-afc-image test-google-rectangle-ads"> <script> (valve = window.valve || []).push(function(v) { v.displayDFPSlot('google_afc_user_container_7'); }); </script> <div id="google_afc_user_container_7" class="google-afc-user-container google_afc_blocklink2_5 google_afc_boder" data-test-unit="/4374287/blog_user_2nd"></div> <a href="http://blog.hatena.ne.jp/guide/pro" class="open-pro-modal" data-guide-pro-modal-ad-url="https://hatena.blog/guide/pro/modal/ad">広告を非表示にする</a> </div> <div class="customized-footer"> </div> <div class="comment-box js-comment-box"> <ul class="comment js-comment"> <li class="read-more-comments" style="display: none;"><a>もっと読む</a></li> </ul> <a class="leave-comment-title js-leave-comment-title">コメントを書く</a> </div> </footer> </div> </article> <!-- rakuten_ad_target_end --> <!-- google_ad_section_end --> <div class="pager autopagerize_insert_before"> <span class="pager-next"> <a href="https://happy-teeth.hatenablog.com/?page=1540806745" rel="next">次のページ</a> </span> </div> </div> </div> <aside id="box1"> <div id="box1-inner"> </div> </aside> </div><!-- #wrapper --> <aside id="box2"> <div id="box2-inner"> <div class="hatena-module hatena-module-profile"> <div class="hatena-module-title"> プロフィール </div> <div class="hatena-module-body"> <a href="https://happy-teeth.hatenablog.com/about" class="profile-icon-link"> <img src="https://cdn.profile-image.st-hatena.com/users/happy_teeth_ago/profile.png" alt="id:happy_teeth_ago" class="profile-icon" /> </a> <span class="id"> <a href="https://happy-teeth.hatenablog.com/about" class="hatena-id-link"><span data-load-nickname="1" data-user-name="happy_teeth_ago">id:happy_teeth_ago</span></a> </span> <div class="hatena-follow-button-box btn-subscribe js-hatena-follow-button-box" > <a href="#" class="hatena-follow-button js-hatena-follow-button"> <span class="subscribing"> <span class="foreground">読者です</span> <span class="background">読者をやめる</span> </span> <span class="unsubscribing" data-track-name="profile-widget-subscribe-button" data-track-once> <span class="foreground">読者になる</span> <span class="background">読者になる</span> </span> </a> <div class="subscription-count-box js-subscription-count-box"> <i></i> <u></u> <span class="subscription-count js-subscription-count"> </span> </div> </div> <div class="profile-about"> <a href="https://happy-teeth.hatenablog.com/about">このブログについて</a> </div> </div> </div> <div class="hatena-module hatena-module-search-box"> <div class="hatena-module-title"> 検索 </div> <div class="hatena-module-body"> <form class="search-form" role="search" action="https://happy-teeth.hatenablog.com/search" method="get"> <input type="text" name="q" class="search-module-input" value="" placeholder="記事を検索" required> <input type="submit" value="検索" class="search-module-button" /> </form> </div> </div> <div class="hatena-module hatena-module-links"> <div class="hatena-module-title"> リンク </div> <div class="hatena-module-body"> <ul class="hatena-urllist"> <li> <a href="https://hatena.blog/">はてなブログ</a> </li> <li> <a href="https://hatena.blog/guide?via=200109">ブログをはじめる</a> </li> <li> <a href="http://blog.hatenablog.com">週刊はてなブログ</a> </li> <li> <a href="https://hatena.blog/guide/pro">はてなブログPro</a> </li> </ul> </div> </div> <div class="hatena-module hatena-module-recent-entries "> <div class="hatena-module-title"> <a href="https://happy-teeth.hatenablog.com/archive"> 最新記事 </a> </div> <div class="hatena-module-body"> <ul class="recent-entries hatena-urllist "> <li class="urllist-item recent-entries-item"> <div class="urllist-item-inner recent-entries-item-inner"> <a href="https://happy-teeth.hatenablog.com/entry/2023/05/05/141921" class="urllist-title-link recent-entries-title-link urllist-title recent-entries-title">Xcode 14.3でシュミレータのビルドエラー</a> </div> </li> <li class="urllist-item recent-entries-item"> <div class="urllist-item-inner recent-entries-item-inner"> <a href="https://happy-teeth.hatenablog.com/entry/2023/05/03/090950" class="urllist-title-link recent-entries-title-link urllist-title recent-entries-title">【XCode】Unable to boot the Simulator. Failed to start launchd_sim: の原因</a> </div> </li> <li class="urllist-item recent-entries-item"> <div class="urllist-item-inner recent-entries-item-inner"> <a href="https://happy-teeth.hatenablog.com/entry/2023/05/02/083929" class="urllist-title-link recent-entries-title-link urllist-title recent-entries-title">wordpress おすすめプラグイン</a> </div> </li> <li class="urllist-item recent-entries-item"> <div class="urllist-item-inner recent-entries-item-inner"> <a href="https://happy-teeth.hatenablog.com/entry/2023/04/28/065129" class="urllist-title-link recent-entries-title-link urllist-title recent-entries-title">ChatGPTの使い方</a> </div> </li> <li class="urllist-item recent-entries-item"> <div class="urllist-item-inner recent-entries-item-inner"> <a href="https://happy-teeth.hatenablog.com/entry/2023/04/27/170816" class="urllist-title-link recent-entries-title-link urllist-title recent-entries-title">M1 MAC環境構築 忘備録</a> </div> </li> </ul> </div> </div> <div class="hatena-module hatena-module-archive" data-archive-type="default" data-archive-url="https://happy-teeth.hatenablog.com/archive"> <div class="hatena-module-title"> <a href="https://happy-teeth.hatenablog.com/archive">月別アーカイブ</a> </div> <div class="hatena-module-body"> <ul class="hatena-urllist"> <li class="archive-module-year archive-module-year-hidden" data-year="2023"> <div class="archive-module-button"> <span class="archive-module-hide-button">▼</span> <span class="archive-module-show-button">▶</span> </div> <a href="https://happy-teeth.hatenablog.com/archive/2023" class="archive-module-year-title archive-module-year-2023"> 2023 </a> <ul class="archive-module-months"> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2023/05" class="archive-module-month-title archive-module-month-2023-5"> 2023 / 5 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2023/04" class="archive-module-month-title archive-module-month-2023-4"> 2023 / 4 </a> </li> </ul> </li> <li class="archive-module-year archive-module-year-hidden" data-year="2022"> <div class="archive-module-button"> <span class="archive-module-hide-button">▼</span> <span class="archive-module-show-button">▶</span> </div> <a href="https://happy-teeth.hatenablog.com/archive/2022" class="archive-module-year-title archive-module-year-2022"> 2022 </a> <ul class="archive-module-months"> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2022/12" class="archive-module-month-title archive-module-month-2022-12"> 2022 / 12 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2022/10" class="archive-module-month-title archive-module-month-2022-10"> 2022 / 10 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2022/08" class="archive-module-month-title archive-module-month-2022-8"> 2022 / 8 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2022/05" class="archive-module-month-title archive-module-month-2022-5"> 2022 / 5 </a> </li> </ul> </li> <li class="archive-module-year archive-module-year-hidden" data-year="2021"> <div class="archive-module-button"> <span class="archive-module-hide-button">▼</span> <span class="archive-module-show-button">▶</span> </div> <a href="https://happy-teeth.hatenablog.com/archive/2021" class="archive-module-year-title archive-module-year-2021"> 2021 </a> <ul class="archive-module-months"> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/12" class="archive-module-month-title archive-module-month-2021-12"> 2021 / 12 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/11" class="archive-module-month-title archive-module-month-2021-11"> 2021 / 11 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/08" class="archive-module-month-title archive-module-month-2021-8"> 2021 / 8 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/07" class="archive-module-month-title archive-module-month-2021-7"> 2021 / 7 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/06" class="archive-module-month-title archive-module-month-2021-6"> 2021 / 6 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/05" class="archive-module-month-title archive-module-month-2021-5"> 2021 / 5 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/04" class="archive-module-month-title archive-module-month-2021-4"> 2021 / 4 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/03" class="archive-module-month-title archive-module-month-2021-3"> 2021 / 3 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/02" class="archive-module-month-title archive-module-month-2021-2"> 2021 / 2 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2021/01" class="archive-module-month-title archive-module-month-2021-1"> 2021 / 1 </a> </li> </ul> </li> <li class="archive-module-year archive-module-year-hidden" data-year="2020"> <div class="archive-module-button"> <span class="archive-module-hide-button">▼</span> <span class="archive-module-show-button">▶</span> </div> <a href="https://happy-teeth.hatenablog.com/archive/2020" class="archive-module-year-title archive-module-year-2020"> 2020 </a> <ul class="archive-module-months"> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/12" class="archive-module-month-title archive-module-month-2020-12"> 2020 / 12 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/11" class="archive-module-month-title archive-module-month-2020-11"> 2020 / 11 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/10" class="archive-module-month-title archive-module-month-2020-10"> 2020 / 10 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/08" class="archive-module-month-title archive-module-month-2020-8"> 2020 / 8 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/07" class="archive-module-month-title archive-module-month-2020-7"> 2020 / 7 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/04" class="archive-module-month-title archive-module-month-2020-4"> 2020 / 4 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/03" class="archive-module-month-title archive-module-month-2020-3"> 2020 / 3 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/02" class="archive-module-month-title archive-module-month-2020-2"> 2020 / 2 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2020/01" class="archive-module-month-title archive-module-month-2020-1"> 2020 / 1 </a> </li> </ul> </li> <li class="archive-module-year archive-module-year-hidden" data-year="2019"> <div class="archive-module-button"> <span class="archive-module-hide-button">▼</span> <span class="archive-module-show-button">▶</span> </div> <a href="https://happy-teeth.hatenablog.com/archive/2019" class="archive-module-year-title archive-module-year-2019"> 2019 </a> <ul class="archive-module-months"> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/12" class="archive-module-month-title archive-module-month-2019-12"> 2019 / 12 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/11" class="archive-module-month-title archive-module-month-2019-11"> 2019 / 11 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/10" class="archive-module-month-title archive-module-month-2019-10"> 2019 / 10 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/09" class="archive-module-month-title archive-module-month-2019-9"> 2019 / 9 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/08" class="archive-module-month-title archive-module-month-2019-8"> 2019 / 8 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/07" class="archive-module-month-title archive-module-month-2019-7"> 2019 / 7 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/06" class="archive-module-month-title archive-module-month-2019-6"> 2019 / 6 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/05" class="archive-module-month-title archive-module-month-2019-5"> 2019 / 5 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/04" class="archive-module-month-title archive-module-month-2019-4"> 2019 / 4 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/03" class="archive-module-month-title archive-module-month-2019-3"> 2019 / 3 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/02" class="archive-module-month-title archive-module-month-2019-2"> 2019 / 2 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2019/01" class="archive-module-month-title archive-module-month-2019-1"> 2019 / 1 </a> </li> </ul> </li> <li class="archive-module-year archive-module-year-hidden" data-year="2018"> <div class="archive-module-button"> <span class="archive-module-hide-button">▼</span> <span class="archive-module-show-button">▶</span> </div> <a href="https://happy-teeth.hatenablog.com/archive/2018" class="archive-module-year-title archive-module-year-2018"> 2018 </a> <ul class="archive-module-months"> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/12" class="archive-module-month-title archive-module-month-2018-12"> 2018 / 12 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/11" class="archive-module-month-title archive-module-month-2018-11"> 2018 / 11 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/10" class="archive-module-month-title archive-module-month-2018-10"> 2018 / 10 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/09" class="archive-module-month-title archive-module-month-2018-9"> 2018 / 9 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/08" class="archive-module-month-title archive-module-month-2018-8"> 2018 / 8 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/07" class="archive-module-month-title archive-module-month-2018-7"> 2018 / 7 </a> </li> <li class="archive-module-month"> <a href="https://happy-teeth.hatenablog.com/archive/2018/06" class="archive-module-month-title archive-module-month-2018-6"> 2018 / 6 </a> </li> </ul> </li> </ul> </div> </div> </div> </aside> </div> </div> </div> </div> <footer id="footer" data-brand="hatenablog"> <div id="footer-inner"> <address class="footer-address"> <a href="https://happy-teeth.hatenablog.com/"> <img src="https://cdn.blog.st-hatena.com/images/admin/blog-icon-noimage.png" width="16" height="16" alt="happy_teeth's 忘備録"/> <span class="footer-address-name">happy_teeth's 忘備録</span> </a> </address> <p class="services"> Powered by <a href="https://hatena.blog/">Hatena Blog</a> | <a href="https://blog.hatena.ne.jp/-/abuse_report?target_url=https%3A%2F%2Fhappy-teeth.hatenablog.com%2F%3Fpage%3D1543383707" class="report-abuse-link test-report-abuse-link" target="_blank">ブログを報告する</a> </p> </div> </footer> <script async src="https://s.hatena.ne.jp/js/widget/star.js"></script> <script> if (typeof window.Hatena === 'undefined') { window.Hatena = {}; } if (!Hatena.hasOwnProperty('Star')) { Hatena.Star = { VERSION: 2, }; } </script> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/ja_JP/sdk.js#xfbml=1&appId=719729204785177&version=v17.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="quote-box"> <div class="tooltip-quote tooltip-quote-stock"> <i class="blogicon-quote" title="引用をストック"></i> </div> <div class="tooltip-quote tooltip-quote-tweet js-tooltip-quote-tweet"> <a class="js-tweet-quote" target="_blank" data-track-name="quote-tweet" data-track-once> <img src="https://cdn.blog.st-hatena.com/images/admin/quote/quote-x-icon.svg?version=e930ff19ae55f4e0f50e8cc5579552" title="引用して投稿する" > </a> </div> </div> <div class="quote-stock-panel" id="quote-stock-message-box" style="position: absolute; z-index: 3000"> <div class="message-box" id="quote-stock-succeeded-message" style="display: none"> <p>引用をストックしました</p> <button class="btn btn-primary" id="quote-stock-show-editor-button" data-track-name="curation-quote-edit-button">ストック一覧を見る</button> <button class="btn quote-stock-close-message-button">閉じる</button> </div> <div class="message-box" id="quote-login-required-message" style="display: none"> <p>引用するにはまずログインしてください</p> <button class="btn btn-primary" id="quote-login-button">ログイン</button> <button class="btn quote-stock-close-message-button">閉じる</button> </div> <div class="error-box" id="quote-stock-failed-message" style="display: none"> <p>引用をストックできませんでした。再度お試しください</p> <button class="btn quote-stock-close-message-button">閉じる</button> </div> <div class="error-box" id="unstockable-quote-message-box" style="display: none; position: absolute; z-index: 3000;"> <p>限定公開記事のため引用できません。</p> </div> </div> <script type="x-underscore-template" id="js-requote-button-template"> <div class="requote-button js-requote-button"> <button class="requote-button-btn tipsy-top" title="引用する"><i class="blogicon-quote"></i></button> </div> </script> <div id="hidden-subscribe-button" style="display: none;"> <div class="hatena-follow-button-box btn-subscribe js-hatena-follow-button-box" > <a href="#" class="hatena-follow-button js-hatena-follow-button"> <span class="subscribing"> <span class="foreground">読者です</span> <span class="background">読者をやめる</span> </span> <span class="unsubscribing" data-track-name="profile-widget-subscribe-button" data-track-once> <span class="foreground">読者になる</span> <span class="background">読者になる</span> </span> </a> <div class="subscription-count-box js-subscription-count-box"> <i></i> <u></u> <span class="subscription-count js-subscription-count"> </span> </div> </div> </div> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> <script src="https://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script> <script type="text/javascript" src="https://cdn.blog.st-hatena.com/js/external/jquery.min.js?v=1.12.4&version=e930ff19ae55f4e0f50e8cc5579552"></script> <script src="https://cdn.blog.st-hatena.com/js/texts-ja.js?version=e930ff19ae55f4e0f50e8cc5579552"></script> <script id="vendors-js" data-env="production" src="https://cdn.blog.st-hatena.com/js/vendors.js?version=e930ff19ae55f4e0f50e8cc5579552" crossorigin="anonymous"></script> <script id="hatenablog-js" data-env="production" src="https://cdn.blog.st-hatena.com/js/hatenablog.js?version=e930ff19ae55f4e0f50e8cc5579552" crossorigin="anonymous" data-page-id="index"></script> <script>Hatena.Diary.GlobalHeader.init()</script> <script id="valve-dmp" data-service="blog" src="https://cdn.pool.st-hatena.com/valve/dmp.js" data-test-id="dmpjs" async></script> </body> </html>