Skip to content

Instantly share code, notes, and snippets.

View TokyoYoshida's full-sized avatar

Junya Yoshida TokyoYoshida

View GitHub Profile
// reference from: https://gist.github.com/algal/8e31ce035af0aafebc3736661ae9e3cd
import Foundation
import ModelIO
private func LogDebug(_ s:Any) -> Void { print(s) }
private func LogInfo(_ s:Any) -> Void { print(s) }
private func LogError(_ s:Any) -> Void { print(s) }
struct POINT3D {
var x:Float
@TokyoYoshida
TokyoYoshida / CodePiece.swift
Created November 19, 2020 04:05
変化しやすいところをクラスにくるんでやると、あとで修正しやすくなる。例えば検索条件をConditionクラスにする。あとで検索キーが複数になっても呼び出す処理は影響しない。修正しやすいということは他の箇所にも転用しやすいということ。 #CodePiece
struct Condition {
let searchKey: String
}
struct Result {}
struct SomeStore {
func search(cond: Condition) -> Result {
let dummyResult = Result()
return dummyResult
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TokyoYoshida
TokyoYoshida / CodePiece.swift
Created October 22, 2020 04:15
ちょっとしたメッセージを表示するビューをBuilderパターンで作ったら柔軟でいい感じになった。これはUILabel用だけど画像を追加したければImageBuilderのようなプロトコルを作ればいい。 #CodePiece
import UIKit
protocol LabelBuilder {
func addLabel(label: UILabel)
func addHorizontalCenterdLabel(text: String)
}
extension LabelBuilder {
func addLabel(label: UILabel) {
// some code
}
func addHorizontalCenterdLabel(text: String) {
@TokyoYoshida
TokyoYoshida / CodePiece.swift
Created October 8, 2020 20:37
変数名は短いのが好き。変数名が長いのは、変数が属しているクラスやメソッドに責務が沢山あるということ。責務を分けていけば、変数名も自然と短くできる。 #CodePiece
class UserPageView: UIView {
let nickNameOnHeader: UILabel
}
// ↓
class UserPage: UIView {
class Header: UIView {
let nickName: UILabel
}
}
@TokyoYoshida
TokyoYoshida / CodePiece.swift
Created October 8, 2020 19:38
変数名は短いほうが好き。変数名が長いということは、クラスやメソッドが沢山の責務を持ってしまっているということ。責務にしたがって分ければ、変数名も自然と短くなる。 #CodePiece
class UserPageView: UIView {
let nickNameOnHeader: UILabel
}
// ↓
class UiserPage: UIView {
class Header: UIView {
let nickName: UILabel
}
}
@TokyoYoshida
TokyoYoshida / CodePiece.swift
Created October 6, 2020 01:01
1行で書くComputed propertyは自然に宣言的になるので好きかも。もちろんPure functionで書く。 #CodePiece
struct S {
let height: Int
let width: Int
var rectangle: Int {
height * width
}
}
@TokyoYoshida
TokyoYoshida / CodePiece.swift
Created October 1, 2020 01:30
インデックスが配列内に収まっているかを判定する方法。もっとエレガントに書く方法ないかな。 #CodePiece
let array = [1,2,3]
let i = 2
if array.startIndex..<array.endIndex ~= i {
print("true")
} else {
print("false")
}

サイダー検出装置プライバシーポリシー

この文書は、AppStoreで公開しているアプリサイダー検出装置における個人情報の保護、および、その取り扱いについての方針を示すものです。

個人情報の定義

サイダー検出装置プライバシーポリシーのアプリを介して接点があった人に関する情報で、下に示す個人を特定する要素が2つ以上組み合わさったものを個人情報と定義します。 <個人を特定する要素> ・氏名 ・メールアドレス ・電話番号

@TokyoYoshida
TokyoYoshida / gist:e51d30a4267d3363cf7569d0cbb19e70
Last active August 12, 2020 07:52
SleepCounterプライバシーポリシー

SleepCounterプライバシーポリシー

この文書は、AppStoreで公開しているアプリSleepCounterにおける個人情報の保護、および、その取り扱いについての方針を示すものです。

個人情報の定義

SleepCounterプライバシーポリシーのアプリを介して接点があった人に関する情報で、下に示す個人を特定する要素が2つ以上組み合わさったものを個人情報と定義します。 <個人を特定する要素> ・氏名 ・メールアドレス ・電話番号