Skip to content

Instantly share code, notes, and snippets.

View s2mr's full-sized avatar
🚀
Writing codes...

Kazumasa Shimomura s2mr

🚀
Writing codes...
View GitHub Profile
@s2mr
s2mr / file0.swift
Last active October 25, 2017 16:39
UITableViewCellをXibから読み込む場合の落とし穴 ref: http://qiita.com/shimokpp/items/686fdbe72018a1553dae
tableView.register(MyChatViewCell.self, forCellReuseIdentifier: "MyChat")
@s2mr
s2mr / ChatRoomInputView.swift
Last active December 19, 2017 06:13
チャットアプリでよくある画面下部のテキストフィールドを実現する ref: https://qiita.com/shimokp/items/a6817fd489c76ed00a65
import UIKit
class ChatRoomInputView: UIView {
@IBOutlet weak var chatTextField: UITextField!
@IBOutlet weak var sendButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
self.setFromXib()
@s2mr
s2mr / CodePiece.swift
Created November 21, 2017 12:38
って書くと一つのインスタンスを参照してしまうんだな。最近参照型と値型の違いを理解したつもりになってたのに、早速罠にハマってしまった。 #CodePiece
var nodes: [Node] = [Node](repeatElement(Node(parent: nil, left: nil, right: nil), count: Int(lines[0])! )) // ノード保持配列の初期化
@s2mr
s2mr / ChatEntity.swift
Last active December 15, 2017 04:57
LINEのようなチャットUIをつくる ref: https://qiita.com/shimokp/items/fd2ba61e8233080bdf07
import Foundation
import UIKit
public class ChatEntity {
var text = ""
var time = ""
var userType: UserType
public init(text: String, time: String, userType: UserType) {
self.text = text
@s2mr
s2mr / APIClient.swift
Created October 11, 2018 01:24
Generics API client
import Foundation
import RxSwift
import Utility
public protocol AppAPIRequest {
associatedtype Response
}
public enum APIRequestState {
case none
@s2mr
s2mr / create-swift-playground.sh
Last active April 13, 2023 05:59
Create swift playground with spm
#!/bin/bash
# You can pass argument as project name.
# If you don't pass argument, use current time for project name.
play-swift() {
CURRENT_DIR="$(pwd)"
PROJECTS_DIR=~/Playgrounds
cd "$PROJECTS_DIR"
REPO_NAME=${1:-$(date +%Y%m%d-%H%M%S)}