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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BallTap : MonoBehaviour, TapBehaviour { | |
/** タッチしたとき */ | |
public void TapDown(ref RaycastHit hit) { | |
Debug.Log("TapDown : " + hit); |
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
override func viewWillDisappear(_ animated: Bool) { | |
/** | |
* UINavigationControllerの戻る[back]処理のイベントを取得する方法 | |
* https://qiita.com/syamaoka/items/509ff50fcab485347600 | |
* ... viewWillDisappearが呼ばれる時に、戻る処理を行っていれば、NavigationControllerのviewControllersの中にselfは存在していない | |
*/ | |
if let viewControllers = self.navigationController?.viewControllers { | |
let existsSelfInViewControllers = viewControllers.filter{$0 == self}.count == 0 | |
if existsSelfInViewControllers { |
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
/** | |
* KVO (Key Value Observer) | |
* | |
* GMSMapView (GoogleMap) の myLocation (CLLocation) の内容が変化したら...を取得 | |
*/ | |
import UIKit | |
import GoogleMaps | |
import CoreLocation |
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
//警告表示 | |
internal alertTest() { | |
let alert = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: .alert) | |
let defaultAction = UIAlertAction(title: "OK", style: .default) { | |
(action) in | |
print("OK") | |
} | |
alert.addAction(defaultAction) |
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
/** | |
* https://stackoverflow.com/questions/24077428/how-do-i-declare-typedef-in-swift | |
*/ | |
//やりたかったこと | |
typealias FunctionClosure = (_ value: Int) -> Void | |
fileprivate var _closure: FunctionClosure? = nil |
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
class sample { | |
/** | |
* メモ | |
* 標準の abs ... abs(Int32) だけなので... Int16 も扱える abs を Generics で試してみた。 | |
* | |
* Generics の 型制限 をできないものかと...ググると SignedNumeric, SignedInteger を指定できる様子。 | |
* ただ... SignedNumeric を指定すると (x < 0) の比較で エラーになるため 整数のみを指定 | |
* Float などもまとめて処理できたらいいな...と思ったが...とりあえず見送り | |
*/ |
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 | |
// Sample | |
// | |
import UIKit | |
// MARK: - | |
extension ViewController { |
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
/** | |
* UITableViewController を継承している場合を想定した例 | |
*/ | |
extension xxxTableViewController { | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
//セルの作成 | |
let cell = UITableViewCell(style: .value1, reuseIdentifier: "cell") | |
//Configure the cell... |
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
/** | |
* メールの送信 ... 大まかには 以下の記事を参考 | |
* https://qiita.com/kobaboy/items/1d8a5c01baf299a8573b | |
* | |
* Documentフォルダの realmファイル を添付したくて試した時のメモ | |
*/ | |
extension ViewController: MFMailComposeViewControllerDelegate { | |
fileprivate func sendMail(subject: String, message: String) { | |
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
//https://stackoverflow.com/questions/39579025/auto-increment-id-in-realm-swift-3-0 | |
//プライマリキーとして次の値を取得 | |
public static func getNextId(_ object: Object) -> Int { | |
//インスタンスからクラスを取得 | |
let model = type(of: object) | |
//Realm | |
let realm = try! Realm() | |