Upgrade to Pro — share decks privately, control downloads, hide ads and more …

「開発初心者は何がわからないのか」 わからないを言語化するヒント

Marina Nakagawa
September 20, 2018
890

「開発初心者は何がわからないのか」 わからないを言語化するヒント

Marina Nakagawa

September 20, 2018
Tweet

More Decks by Marina Nakagawa

Transcript

  1. 14 class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor =

    UIColor.white let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } }
  2. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 15 ͑ͬɹViewControllerͬͯͳʹʁ ϧʔϓͲ͜ʁʁʁ ProcessingͩͬͨΒdraw()ؔ਺Έ͍ͨͳ΍ͭͲ͜΍ɾɾɾ
 ྫ ↓͜Μͳ΍ͭ void setup() { size(250, 250); frameRate(20); } void draw() { background(0); ellipse(width/2, height/2, mouseX, mouseY); }
  3. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 16 overrideɾɾɾɾʁ
  4. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 17 ͜ͷselfͬͯԿʁ
 Ͳ͏ͯ࣍͠ʹ.view͕ͭͳ͕Δͷʁ
  5. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 18 ͜Εؔ਺͔ͳʁʁ
  6. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 19 labelͷtextʹ୅ೖͯ͠ΔΒ͍͠ ͜Ε͸Θ͔Δ
  7. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 20 ͜ͷ {}Ͱғ·ΕͯΔͷ͸ԿʁͳΜͰ{}ͰғΉͷʁ
  8. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 21 .verticalΛ୅ೖ͢ΔͬͯԿʁʁɹ͜ͷ఺(.)Կʁ
  9. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 22 ͳΜͰಥવreturn͢Δͷ
  10. class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white

    let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() ~~~~~~~~~~~~~~~~~~লུ~~~~~~~~~~~~~~ } } 23 ͜ͷ࠷ޙͷ()ԿʁʁͳΜͰඞཁͳͷʁ
  11. 27 import UIKit class MyClass { var msg = "ϋϩʔ"

    func hello(){ print(msg) } } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let myObj = MyClass() myObj.hello() myObj.msg = "͸͍" myObj.hello() ~~~~~লུ~~~~~ } class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() } } ৄࡉ!Swift3iPhoneΞϓϦ։ൃೖ໳ϊʔτΑΓൈਮ ΫϥεΛཧղ͔ͨͬͨ͠ͷͰ·ͣ͸ࣸܦΛͯ͠Έͨ
  12. 28 import UIKit class MyClass { var msg = "ϋϩʔ"

    func hello(){ print(msg) } } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let myObj = MyClass() myObj.hello() myObj.msg = "͸͍" myObj.hello() ~~~~~লུ~~~~~ } class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() } } ৄࡉ!Swift3iPhoneΞϓϦ։ൃೖ໳ϊʔτΑΓൈਮ ࣗ෼Ͱॻ͍ͨ͠
 ఆٛͷ࢓ํ͸Θ͔Δͧ ͳΜͱͳ͘ཧղͰ͖ͨؾʹͳΔ
  13. 29 import UIKit class MyClass { var msg = "ϋϩʔ"

    func hello(){ print(msg) } } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let myObj = MyClass() myObj.hello() myObj.msg = "͸͍" myObj.hello() ~~~~~লུ~~~~~ } class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue let myStackView: MyStackView = { let myStackView = MyStackView() myStackView.axis = .vertical myStackView.translatesAutoresizingMaskIntoConstraints = false myStackView.title = "ͯ͢ͱͯ͢ͱ" return myStackView }() } } ৄࡉ!Swift3iPhoneΞϓϦ։ൃೖ໳ϊʔτΑΓൈਮ ͳΜͱͳ͘Θ͔ͬͨͧ ͳΜͱͳ͘ཧղͰ͖ͨؾʹͳΔ
  14. 30 import UIKit class MyClass { var msg = "ϋϩʔ"

    func hello(){ print(msg) } } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let myObj = MyClass() myObj.hello() myObj.msg = "͸͍" myObj.hello() ~~~~~লུ~~~~~ } class ViewController: UIViewController{ override func viewDidLoad() { self.view.backgroundColor = UIColor.white let label = UILabel() label.text = "aaaa" label.textColor = UIColor.blue ৄࡉ!Swift3iPhoneΞϓϦ։ൃೖ໳ϊʔτΑΓൈਮ ࣮ࡍͷΞϓϦ։ൃͰԠ༻͕͖͔ͳ͍ ͑ͬ͜ͷtextͲ͔͜Β͖ͨʁ ࣗ෼Ͱॻ͍ͯͳ͍Α ͑ͬࠓ·ͰMyClassͬͯॻ͍ͯͨͷʹ
 UILabel()ͬͯԿʁʁʁ
  15. 33 ࢲͷ৔߹ɹ ϝϯλʔʹࣗ෼ͷߟ͑ΛݴͬͯؒҧͬͯͨΒࢦఠͯ͠΋Βͬͨ @available(iOS 2.0, *) open class UILabel :

    UIView, NSCoding, UIContentSizeCategoryAdjusting { open var text: String? // default is nil open var font: UIFont! // default is nil (system font 17 plain) ͜ΕϓϩύςΟ໊ͩΑͶʁ ͜ΕͬͯΫϥε໊Ͱ͢ΑͶʁ ͜Ε͸਌Ϋϥε͔ͳʁ ͜Ε͸ϓϩτίϧ͔ͳʁ ͜Ε͸ܕͩΑͶʁ
  16. 36 ಛʹ઀ඌΫϩʔδϟʔɹলུ͕೉͍͠ //Ҿ਺͕ΫϩʔδϟʔͰҰ͔ͭ͠ͳ͍৔߹ͷྫ let array = [1,2,3,4,5] let newArray =

    array.map({ $0 * 2 }) //↑[2, 4, 6, 8, 10]ʹͳΔ //ޙஔه๏Ͱॻ͘ͱ let newArray = array.map(){ $0 * 2 } //↓΋ͬͱলུ͢Δͱ()Λলུͯ͠΋͍͍ //ʢωοτͰௐ΂ͯ΋ԼهͷΑ͏ͳྫͰॻ͔Ε͍ͯͯলུ͞ΕͯΔͷʹؾ͕͔ͭͳ͍ʣ let newArray = array.map{ $0 * 2 }
  17. 37 ࣮ࡍʹͲ͏͍͏ͱ͜ΖͰ٧·Δͷ͔(ϦΫΤετΛૹΔྫ) var request = URLRequest(url: url) request.httpMethod = "GET"

    let task = URLSession.shared.dataTask(with: request){ (data, response, error) in guard let data = data else { return } ~~~~~~~ লུ ~~~~~~~~~ } ͳΜͰؔ਺ͷޙΖʹ{}͕͍ͭͯΔΜͩɾɾɾ
 (઀ඌΫϩʔδϟʔͬͯؾ͕͍͍ͭͯͳ͍)
  18. 38 ࣮ࡍʹͲ͏͍͏ͱ͜ΖͰ٧·Δͷ͔(ϦΫΤετΛૹΔྫ) var request = URLRequest(url: url) request.httpMethod = "GET"

    let task = URLSession.shared.dataTask(with: request){ (data, response, error) in guard let data = data else { return } ~~~~~~~ লུ ~~~~~~~~~ } ͜ͷ data , response, errorͬͯͲ͏ͯ͠
 w w w w w w w w w w w w w w w w w w w w w w w w w ͜Μͳ໊લΛ͚ͭͨͷʁ
 w w w w w w w w w w Ͳ͜ΛΈͯͦ͏ॻ͚ΔͬͯΘ͔ͬͨͷʁ w w w w w w w w w w w w w w w w w
  19. 41 dataTaskͷఆٛΛݟͯΈΔ open func dataTask(with request: URLRequest, completionHandler: @escaping (Data?,

    URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask ໼ҹ͕͍ͬͺ͍ͰԿ͕ͳΜ͔ͩɾɾɾ
 Θ͔Βͳ͍ɾɾɾɾ
 ΋͏͍͍΍ɾɾɾఘΊ
  20. 43 dataTaskͷఆٛΛݟͯΈΔ(ࠓͩͬͨΒ) open func dataTask(with request: URLRequest, completionHandler: @escaping (Data?,

    URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask ·ͣ͸ୈҰҾ਺ with͸ϥϕϧ໊ͩͳ
 request͸Ҿ਺໊
 ͜͜ʹೖΔҾ਺ͷܕ͸URLRequestͩͳ
  21. 44 dataTaskͷఆٛΛݟͯΈΔ(ࠓͩͬͨΒ) open func dataTask(with request: URLRequest, completionHandler: @escaping (Data?,

    URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask ୈೋҾ਺ͷҾ਺໊͸CompletionHandlerͩͳ
 ೖΔܕ͸ɾɾɾ͋ͬɹ͍ͭ͜Ϋϩʔδϟʔͩ
 ͲΜͳΫϩʔδϟʔ͔ͱ͍͏ͱ(Data?ܕ, URLResponse?ܕ, Error?ܕ)ͷҾ਺ͰฦΓ஋͕Swift.VoidܕͳΜͩͶ @escaping͕͍͍ͭͯΔͱ͍͏͜ͱ͸ڧࢀর͔ඇಉظͰ࣮ߦ͞ΕΔͷ͔ͳʁ
 Ϋϩʔδϟʔͱ͍͏͜ͱ͸઀ඌΫϩʔδϟʔͰୈೋҾ਺ʹೖΕͣʹޙΖʹ͚ͬͭͯ͘΋OKͩΑͶ
  22. 45 dataTaskͷఆٛΛݟͯΈΔ(ࠓͩͬͨΒ) open func dataTask(with request: URLRequest, completionHandler: @escaping (Data?,

    URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask ͜ͷؔ਺ͷฦΓ஋ͷܕ͸URLSessionDataTaskͳͷ͔
  23. 50 ͜Μͳײ͡Ͱఆٛͷ෼ྨ(Ҿ਺໊ɺܕɺฦΓ஋ͷܕ)͔Β͸͡ΊͯΈΔ open func dataTask(with request: URLRequest, completionHandler: @escaping (Data?,

    URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask ୈҰҾ਺ʹ໊̎ͭલ͕ೖͬͯΔ
 with͸ϥϕϧ໊Ͱɹrequest͕Ҿ਺໊ͩͶ ؔ਺ݺ͹ΕΔͱ͖ʹ࢖ΘΕΔͷ͸withͩͶ ୈҰҾ਺ͷܕ͸URLRequestܕͩ ୈҰҾ਺ ୈೋҾ਺ ୈҰҾ਺ͷܕ ୈೋҾ਺ͷܕ ฦΓ஋ͷܕ