This file contains hidden or 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 | |
| protocol AvoidRerender: class { | |
| associatedtype TargetState: Equatable | |
| // この記事を書いている途中で、これがinternalなのはまずいことに気付いた。が、現状どうしようもない。 | |
| var state: TargetState? { get set } | |
| func update(with state: TargetState?) | |
| func customAction(state: TargetState?) |
This file contains hidden or 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
| set PATH $HOME/.nodebrew/current/bin $PATH | |
| function cd | |
| if test (count $argv) -eq 0 | |
| builtin cd | |
| return 0 | |
| else if test (count $argv) -gt 1 | |
| printf "%s\n" (_ "Too many args for cd command") | |
| return 1 | |
| end |
This file contains hidden or 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
| resources: | |
| - name: as_you_like | |
| type: git | |
| source: | |
| uri: git@github.com:your/private-repository.git | |
| branch: master | |
| private_key: | | |
| -----BEGIN RSA PRIVATE KEY----- | |
| MIIEowIBAAKCAQEAw0ej | |
| (中略) |
This file contains hidden or 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 | |
| // UI | |
| class ViewController: UIViewController, ModelDelegate { | |
| let model = Model() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() |
This file contains hidden or 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/Foundation.h> | |
| typedef enum : NSInteger { | |
| EnumHogeType1, | |
| EnumHogeType2, | |
| } EnumHoge; | |
| typedef NS_ENUM(NSInteger, EnumFuga) { | |
| EnumFugaType1, | |
| EnumFugaType2 |
This file contains hidden or 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
| typealias Pair = (Int, Int) | |
| // 要素数21個の場合 | |
| let array1 = (0 ... 20).map { i in | |
| Pair(i / 5, i) | |
| } | |
| // tupleの2つめの要素でsortしてから | |
| let sorted1 = array1.sorted { (p1, p2) in |
This file contains hidden or 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 MapKit | |
| class ViewController: UIViewController { | |
| /* ドラッグの位置記憶用の変数 */ | |
| var dragPoint: CGPoint? | |
| var mapView: MKMapView! | |
| override func viewDidLoad() { |
This file contains hidden or 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 | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let textField = UITextField(frame: CGRect(x: 100, y: 100, width: 50, height: 30)) | |
| textField.backgroundColor = UIColor.redColor() | |
| view.addSubview(textField) |
This file contains hidden or 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 Test: NSObject { | |
| func test() { | |
| let swifter = Swifter(consumerKey: TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_SECRET, oauthToken: TWITTER_ACCESS_TOKEN, oauthTokenSecret: TWITTER_ACCESS_TOKEN_SECRET) | |
| let dictionary = ["hoge" : "fuga"] | |
| let string = dictionary.description | |
| swifter.postStatusUpdate(string, success: { status in | |
| }, failure: { error in | |
| print(error) | |
| }) | |
| } |
This file contains hidden or 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
| var oldSet = NSSet(array: ["oldValue1", "oldValue2"]) | |
| var oldValue1: String | |
| oldValue1 = oldSet.anyObject() as! String //キャストが必要 | |
| var newSet = Set<String>(arrayLiteral: "newValue1", "newValue2") | |
| var newValue1: String | |
| newValue1 = newSet.first! // キャスト不要 |