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
# ~/.config/fish/functions/xcode.fish | |
function xcode -d "Open file by Xcode" | |
set -l file $argv[1] | |
set -l a_option $argv[2] | |
set -l application $argv[3] | |
if test -z $a_option | |
set a_option -a | |
set application Xcode |
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
import Foundation | |
enum Phrase: Int, CustomStringConvertible { | |
case zun = 0 | |
case doko = 1 | |
var description: String { | |
switch self { | |
case .zun: | |
return "ずん" |
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
let values: [Int?] = [1, 2, nil, 4, 5] | |
for value in values where value != nil { | |
print(value!, type(of: value!)) | |
} | |
for case let value? in values { | |
print(value, type(of: value)) | |
} |
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
# This is Git's per-user configuration file. | |
[user] | |
name = | |
email = | |
[core] | |
excludesfile = | |
[color] | |
ui = auto | |
[difftool "sourcetree"] | |
cmd = opendiff \"$LOCAL\" \"$REMOTE\" |
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
let data = """ | |
[ | |
{"id": 1, "name": "yutaro"}, | |
{"id": 2, "name": "yutailang"} | |
] | |
""".data(using: .utf8)! | |
struct User: Codable, CustomStringConvertible { | |
let id: Int | |
let name: 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
import UIKit | |
// Genericsだけでreturnの型を決めたい | |
struct GenerucTest1<ViewType: UIView> { | |
func loadView() -> ViewType { | |
return UIView() // error return UIView() as! ViewType | |
} | |
} |
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
//例えばUITableViewの更新 | |
@IBOutlet weak var tableView: UITableView! | |
let str = "hoge" | |
// 1 | |
let complete1 = { [weak self]() in | |
if let weakSelf = self { | |
print(weakSelf.str) // プロパティにアクセスする => str | |
weakSelf.tableView.reloadData() // メソッドを使う |
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
// Swift2.x | |
dispatch_async(dispatch_get_main_queue()) { [weak self]() in | |
if let weakSelf = self { | |
weakSelf.tableView.reloadData() | |
} | |
} | |
//Swift3.0 | |
DispatchQueue.main.async { [weak self] in | |
if weakSelf = 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
struct Hoge { | |
let id: Int | |
let title: String | |
let fuga: Fuga? //更にstructを内包 | |
//メンバワイズイニシャライザ | |
init(id: Int, title: String,fuga: Fuga?) { | |
self.id = id | |
self.title = title | |
self.fuga = fuga |
NewerOlder