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 | |
class ViewController: UIViewController, UITextFieldDelegate { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
textField.addTarget(self, action: "hoge:", forControlEvents: UIControlEvents.EditingChanged) |
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 | |
// !!! プロトコルの採用とDelegateのセット忘れでつまづく(※ここではStoryboard上でVCと紐付けています) !!! | |
// textField.delegate = selfのことです。 | |
class ViewController: UIViewController, UITextFieldDelegate { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() |
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 | |
class ViewController: UIViewControlle { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// !!! なんか長い !!! |
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 | |
import RxSwift | |
import RxBlocking | |
import RxCocoa | |
class ViewController: UIViewController { | |
@IBOutlet weak var textField: UITextField! | |
@IBOutlet weak var label: UILabel! | |
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 | |
import RxSwift | |
import RxBlocking | |
import RxCocoa | |
class ViewController: UIViewController { | |
@IBOutlet weak var textField: UITextField! | |
@IBOutlet weak var label: UILabel! | |
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 | |
class ViewController: UIViewControlle { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// !!! なんか長い !!! |
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かな | |
enum Element { | |
case Electric, Fire | |
} | |
/********** Abstract Pokemon **********/ |
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
// 非参照型を使って副作用の少ないコードに、かつタイプセーフにしたい = swifty!!! | |
hogehoge() { [weak self] data, response, error in | |
// guardすることでnilでないことを今後保証する | |
guard let data = data else { return } | |
guard let newArray = data["populations"] as? [Population] else { return } | |
// 中身がPopulation型であることを保証するarray(タイプセーフ) | |
var populationArray: [Population] = [] |
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
var array = [1, 2, 3] | |
array.forEach { test($0) } | |
func test(num: Int) { | |
print(num) | |
} |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
enum Element { | |
case Water, Fire, Thunder | |
} | |
protocol Magic { | |
typealias MagicType |
OlderNewer