func startBatteryMonitoring() {
UIDevice.current.isBatteryMonitoringEnabled = true
// バッテリー残量の変化を監視
NotificationCenter.default.addObserver(
self,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Koshian.swift | |
// | |
// Created by Kazuo Tsubaki on 2018/03/09. | |
// Copyright © 2018年 Kazuo Tsubaki. All rights reserved. | |
// | |
import Foundation | |
import CoreBluetooth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// SimpleCoreMLApp | |
// | |
// Created by Kazuo Tsubaki on 2018/03/12. | |
// Copyright © 2018年 Kazuo Tsubaki. All rights reserved. | |
// | |
import UIKit | |
import AVFoundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func drawRoute(_ route: MKRoute) { | |
// 経路を囲む矩形を得る | |
let mapRect = route.polyline.boundingMapRect | |
// リージョンに変換 | |
var region = MKCoordinateRegionForMapRect(mapRect) | |
// リージョンを大きさを少しだけ大きく広げる | |
let span = MKCoordinateSpanMake(region.span.latitudeDelta * 1.1, region.span.longitudeDelta * 1.1) | |
region.span = span | |
// 描画済みのポリラインを削除 | |
mapView.removeOverlays(mapView.overlays) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Talker.swift | |
* | |
* Author: Kazuo Tsubaki - tsubakicraft.jp | |
* | |
* 使用法: | |
* 1文を読み上げる | |
* Talker.shared.play("天気は晴れです") | |
* | |
* 複数の文を読み上げる |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WeatherService.swift | |
* Author: Kazuo Tsubaki - tsubakicraft.jp | |
* | |
* 20分に一回天気を検索する例 | |
* | |
* 使用例 | |
* | |
* (WeatherServiceインスタンスを設定して自分をデリゲートに設定) | |
* let weatherService = WeatherService() |
事前にOpenWeatherMapのAPIキーの取得が必要です。
import MapKit
...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// ObjectTracking | |
// | |
// Created by Kazuo Tsubaki on 2018/03/13. | |
// Copyright © 2018年 Kazuo Tsubaki. All rights reserved. | |
// | |
import UIKit | |
import AVFoundation |