iOS アプリ作成入門

9b6ca173883528d3bd047ca8f20b0bce?s=47 nonylene
March 13, 2016

iOS アプリ作成入門

9b6ca173883528d3bd047ca8f20b0bce?s=128

nonylene

March 13, 2016
Tweet

Transcript

  1. J04ΞϓϦ࡞੒ೖ໳ ,.$OPOZMFOF

  2. ͜ͷεϥΠυʹ͍ͭͯ w य़߹॓Ͱൃදͨ͠΋ͷ w "OESPJEฤʢ຅εϥΠυʣ΋͋Γ·ͪ͢͜Β

  3. ࣗݾ঺հ w OPOZMFOF ͷʹΕΜ  w ,.$ೋճੜSPPU w (JU)VCIBUFOBFUDʜ w

    QZUIPO KBWB "OESPJE 
 ,PUMJOFUDʜ
  4. ࿩͢͜ͱ

  5. J04ͷجຊ

  6. J04ΞϓϦ࣮૷

  7. ࡞੒͢ΔΞϓϦ

  8. 4UBDL0WFSqPXݕࡧ

  9. 4UBDLFS

  10. ."%&*/ )"/"4&

  11. ࢖͏"1* w 4UBDL0WFSqPX"1* w ΈΜͳେ޷͖ɺϓϩάϥϛϯάͷ2"αΠτ w QVCMJD"1*Ͱݕࡧ΍ৄࡉ͕औΕΔ

  12. 4UBDL0WFSqPX"1* w υΩϡϝϯτ w IUUQTBQJTUBDLFYDIBOHFDPNEPDT w TFBSDI"1* ྫλΠτϧʹ4XJGU  w

    IUUQTBQJTUBDLFYDIBOHFDPNTFBSDI PSEFSEFTDTPSUBDUJWJUZJOUJUMFTXJGUTJUF TUBDLPWFSqPXpMUFS GQO[U%1
  13. None
  14. (JU)VC IUUQTHJUIVCDPN OPOZMFOF4UBDLFSJ04

  15. 8IZJ04 w "OESPJEΛͯ͠Δͱત·͘͠ͳΔ w TXJGU࠷ߴͦ͏ w ΤϛϡϨʔλૣͦ͏ w όʔδϣϯ໰୊ͳͦ͞͏ w

    ؀ڥྑͦ͞͏ w ྡࣳ੨໰୊
  16. ໨࣍ w J04ͱ͸ w ηοτΞοϓɾ)FMMP8PSME w ΞϓϦΛ࡞Δ w ײ૝

  17. J04

  18. J04ͱ͸ w "QQMFͷ04 w .BD049Λ࠶ߏ੒ͨ͠΋ͷ w J1IPOFJ1PEUPVDIJ1BE w ೔ຊʹ͓͚ΔγΣΞ͸ w

    ࠷৽͸
  19. ։ൃ؀ڥ w 0CK$4XJGU w ݩʑ0CK$ͷΈ͕ͩͬͨɺ
 ೥ʹ৽ݴޠ4XJGU͕ొ৔ w ࠓճ͸4XJGUΛ࢖͍·͢

  20. ։ൃ؀ڥ w 9DPEF w "QQMFͷ04༻ͷ*%& w "QQMF੡ɺNBDݶఆ w ࣮࣭ແྉ NBDΛങ͑͹

  21. 4XJGUͷจ๏ʢܰ͘ʣ class Piyo : Foo { var text: String? func

    makeHoge(str: String) -> Bar { self.text = str let hoge = Hoge(text: str) return home as! Bar } func printText() { print("text: " + text!) } } Optional
 (Nullable) Unwrap
 (NonNull) ఆ਺ ม਺ ֎෦Ҿ਺໊ Ωϟετ
  22. ηοτΞοϓ

  23. ςϯϓϨʔτ w 4JOHMF7JFX"QQMJDBUJPOΛબ୒

  24. ໊শઃఆ w "OESPJEͱಉ༷4UBDLFSʹ w ݴޠ͸4XJGU

  25. όʔδϣϯ w J04͸ػछ͕"QQMF୺຤ͷΈ w ʢαϙʔτର৅ʣػछ͝ͱͷόʔδϣϯ͕ࠩͳ͍ w ࠷௿όʔδϣϯΛେ͖ΊʹઃఆͰ͖Δ

  26. ΞϓϦΛىಈ w ୺຤Λ઀ଓɺ্ʹ͋Δl⾣z Λԡͯ͠ΞϓϦΛىಈ w J04͸ΤϛϡϨʔλ͕ૣ͍ w ࣮ػσόοά΋ແྉԽ

  27. ॳظঢ়ଶΛோΊΔ

  28. 7JFX$POUSPMMFSTXJGU class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad()

    } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } } w ը໘੍ޚ w ಛʹԿ΋͍ͯ͠ͳ͍
  29. .BJOTUPSZCPBSE

  30. 4UPSZ#PBSE w ը໘ͷભҠ΍ϨΠΞ΢τͳͲΛܾఆ͢Δ w جຊతʹ͸9DPEFΛ௨ͯ͡࢖͏ w ࢖͍ํ͸ޙͰઆ໌ w ࣮ଶ͸YNM w

    ࠓ͸ViewController͕Ұͭ͋ΔͷΈ
  31. 1SPKFDU&EJUPS w ϓϩδΣΫτͷઃఆ w Ϗϧυ w ໊લ w όʔδϣϯ w

    FUDʜ
  32. )FMMP8PSME

  33. 4UPSZ#PBSEΛ։͘

  34. -BCFMΛυϥοάͯ͠഑ஔ https://gyazo.com/1ed1655e91611e4808c1f7b6dd71102a

  35. )FMMP 8PSMEͱهೖ

  36. ΞϓϦΛىಈ

  37. J04 w ϨΠΞ΢τߏ੒͸͜ͷΑ͏ʹ4UPSZ#PBSEͰߦ͏ w Ϛ΢ε͕͋Δͱศར w ը໘͕େ͖͍ͱศར

  38. ΞϓϦ࡞੒

  39. ϑϩʔΛߟ͑Δ ᶃݕࡧϫʔυΛೖྗͤ͞Δ ᶅ"1*Λୟ͍ͯ݁ՌΛऔಘ ᶅ+40/Λॲཧ ᶆॲཧͨ݁͠ՌΛදࣔ͢Δ

  40. ᶃݕࡧϫʔυΛೖྗ

  41. ϨΠΞ΢τ࡞੒

  42. ը໘Λ૊ΈཱͯΔ w ը໘ύʔπͷ͜ͱΛViewͱ͍͏ w ೖྗཝͱϦετදࣔͷύʔπΛ্Լʹฒ΂Δ

  43. 4FBSDI#BSͷઃஔ

  44. 5BCMF7JFXͷઃஔ

  45. 5BCMF7JFXΛ޿͛Δ

  46. w 4FBSDI#BS w ݕࡧόʔ w 5BCMF7JFX w ಉ͡छྨͷ7JFXΛ܁Γฦ͠දࣔ͢Δ w ޙͰৄ͘͠આ໌

    5BCMF7JFX4FBSDI#BS
  47. 4FBSDI#BSͷઃఆ ೖྗώϯτ ςʔϚ

  48. ϓϨϏϡʔ w "TTJTUBOU&EJUPSΛ࢖͏

  49. ϓϨϏϡʔ w ӈଆදࣔʹ1SFWJFXΛબ୒

  50. 7JFX่յ

  51. 8IZ w ੲ͸J04͸ը໘αΠζ͕ಉͩͬͨ͡ w ͜ͷ࣌͸αΠζݻఆͰେৎ෉ͩͬͨ w ࠓ͸σόΠεʹΑͬͯҟͳΔ ˠ ಛఆͷը໘αΠζͰௐ੔͢ΔͱଞͰ߹Θͳ͍

  52. "VUP-BZPVU w 7JFXͷҐஔɾαΠζΛ
 ʮ੍໿ $POTUSBJO ʯͰࢦఆ͢Δ w ࠓ·Ͱ͸ઈରతɺ͜Ε͸૬ରత

  53. "VUP-BZPVU w ଞʢ਌ʣͷ7JFXͱͷʜ w ڑ཭Λࢦఆ͢Δ w 9Λἧ͑Δ w ෯Λἧ͑Δ w

    ॎԣൺΛࢦఆ͢ΔFUDʜ
  54. "VUP-BZPVU w 7JFXΛબ୒ɺӈԼͷϘλϯ܈Ͱࢦఆ

  55. 4FBSDI#BSͷ੍໿ w ্Լࠨӈͷ7JFXͱ઀͢Δ ੍໿ͷ௥Ճ

  56. 4FBSDI#BSͷ੍໿ w ্Լࠨӈͷ7JFXͱ઀͢Δ

  57. 5BCMF7JFXͷ੍໿ w Լࠨӈͷ7JFXͱ઀͢Δ w ্͸4FBSDI#BSͳͷͰ ΋͏ܾఆ͍ͯ͠Δ

  58. 5BCMF7JFXͷ੍໿ w Լࠨӈͷ7JFXͱ઀͢Δ w ্͸4FBSDI#BSͳͷͰ ΋͏ܾఆ͍ͯ͠Δ

  59. 7JFX੒ޭ

  60. ΞϓϦΛىಈ w Ϧετ෦෼͸ۭന w ԿΛදࣔͤ͞Δ͔Λ
 ·ܾͩΊ͍ͯͳ͍

  61. 4FBSDIˠจࣈྻऔಘ

  62. ϑϩʔ w Ϣʔβʔ͕4FBSDIΛ࣮ߦ &OUFSΩʔ  w ͦΕʹԠͯ͡(&5 3FRVFTUΛඈ͹͢ ᶄ

  63. 7JFX$POUSPMMFSͷ࡞੒ɾඥ෇͚

  64. 7JFX$POUSPMMFS w ViewΛ؅ཧ͢ΔΫϥε w ࠓ·Ͱ͸ViewControllerͷදࣔ͢ΔView Λઃఆ͍ͯͨ͠

  65. .BJO7JFX$POUSPMMFS࡞੒ w ੍ޚͷͨΊʹMainViewControllerΛ࡞੒͢Δ

  66. .BJO7JFX$POUSPMMFS࡞੒ w ੍ޚͷͨΊʹMainViewControllerΛ࡞੒͢Δ

  67. 7JFX$POUSPMMFSͷؔ࿈෇͚ w $VTUPN$MBTTʹઃఆ

  68. 7JFXͷඥ෇͚ w "TTJTUBOU&EJUPSӈʹMainViewController

  69. 7JFXͷඥ෇͚ w 7JFXΛબ୒$USMΛԡ͠ͳ͕Βυϥοά

  70. 7JFXͷඥ෇͚ w ૠೖ͍ͨ͠৔ॴʹΧʔιϧΛ߹ΘͤΔ

  71. 7JFXͷඥ෇͚ w ໊લΛೖྗ

  72. 7JFXͷඥ෇͚ w ඥ෇͚׬ྃʂʂʂ

  73. https://gyazo.com/10b37a14a684630c5d176d95ca529180

  74. Ωʔϫʔυऔಘ

  75. Ωʔϫʔυऔಘ • Ϣʔβʔ͕ݕࡧΛ࣮ߦ͢Δ → func searchBarSearchButtonClicked
 (searchBar: UISearchBar)
 ͕ݺ͹ΕΔ →

    searchBar ͔ΒςΩετΛऔಘ͢Δ
  76. import UIKit class MainViewController: UIViewController, UISearchBarDelegate { @IBOutlet weak var

    searchBar: UISearchBar! @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() searchBar.delegate = self } } 6*4FBSDI#BS%FMFHBUF • UISearchBarDelegate Λ࣮૷
 (SearchBar ؔ܎ͷϝιουΛ࣮ߦͰ͖ΔΑ͏ʹ͢Δ)
  77. import UIKit class MainViewController: UIViewController, UISearchBarDelegate { @IBOutlet weak var

    searchBar: UISearchBar! @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() searchBar.delegate = self } } • searchBar ؔ܎ͷϝιουͷݺͼઌΛ self(ࣗ෼) ʹ 6*4FBSDI#BS%FMFHBUF
  78. ϘλϯͷΫϦοΫ import UIKit class MainViewController: UIViewController, UISearchBarDelegate { … override

    func viewDidLoad() { super.viewDidLoad() searchBar.delegate = self } func searchBarSearchButtonClicked(searchBar: UISearchBar) { let searchText = searchBar.text } } • searchBarSearchButtonClicked ͕ݺ͹ΕΔͷͰɺ
 searchBar ͷςΩετΛऔಘ
  79. "MFSUʹग़ͯ͠ΈΔ

  80. ᶄ"1*Ͱ+40/औಘ

  81. ωοτϫʔΫ w ࠓճ͸ϥΠϒϥϦΛ࢖Θͣʹੜ4XJGUͰ

  82. func searchBarSearchButtonClicked(searchBar: UISearchBar) { let searchText = searchBar.text let encodedText

    = searchText!.
 stringByAddingPercentEncodingWithAllowedCharacters(
 .URLQueryAllowedCharacterSet())! let url = "https://api.stackexchange.com/2.2/search?~~~~" +
 encodedText + "&site=stackoverflow&filter=! 6JEajsykLFu3W" } 63-Λ࡞੒ w  63- Τϯίʔυ
  83. ϦΫΤετΛ౤͛Δ w J04Ͱ͸6*ͷߋ৽ʹ࢖͏εϨου͸Ұͭ w ͜ͷεϨουҎ֎Ͱ6*ؔ܎Λ࿔ΔͱΤϥʔ w ωοτϫʔΫͷϦΫΤετ͸ɺ
 ϝΠϯεϨουͰߦ͏΂͖Ͱ͸ͳ͍ w ϦΫΤετʹ͕͔͔࣌ؒΔͱը໘͕ݻ·ΔͨΊ

  84. ϦΫΤετΛ౤͛Δ • NSURLSession w όοΫάϥ΢ϯυͰ௨৴ͯ͘͠ΕΔ w J04ΑΓ࢖͏͜ͱ͕Ͱ͖Δ

  85. NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: url)!,
 completionHandler: {data, response, error in … dispatch_async(dispatch_get_main_queue(), {

    let message = NSString(data: data!, …)! as String let alert = UIAlertController(…, message: message, …) alert.addAction(UIAlertAction(title: "OK", …)) self.presentViewController(alert, …) }) }).resume() • ϥϜμࣜͷ಺෦͸ϝΠϯεϨουͰ͸ͳ͍ • ΞϥʔτΛग़͍͕ͨ͠མͪͯ͠·͏ /463-4FTTJPOΛ࢖ͬͨϦΫΤετ
  86. NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: url)!,
 completionHandler: {data, response, error in … dispatch_async(dispatch_get_main_queue(), {

    let message = NSString(data: data!, …)! as String let alert = UIAlertController(…, message: message, …) alert.addAction(UIAlertAction(title: "OK", …)) self.presentViewController(alert, …) }) }).resume() • dispatch_get_main_queue() Λ࢖ͬͯ
 ϝΠϯεϨουͰ࣮ߦ • ͜͜Ͱ͸ΞϥʔτΛग़͍ͯ͠Δ /463-4FTTJPOΛ࢖ͬͨϦΫΤετ
  87. ᶅ+40/Λॲཧ

  88. +40/Λύʔε try! NSJSONSerialization.JSONObjectWithData(data!, 
 options:NSJSONReadingOptions.MutableContainers) 
 as! NSDictionary as! [String:

    AnyObject] • KTPOΛΦϒδΣΫτʹม׵
  89. +40/Λύʔε try! NSJSONSerialization.JSONObjectWithData(data!, 
 options:NSJSONReadingOptions.MutableContainers) 
 as! NSDictionary as! [String:

    AnyObject] • NSDictionary ʹม׵
  90. +40/Λύʔε try! NSJSONSerialization.JSONObjectWithData(data!, 
 options:NSJSONReadingOptions.MutableContainers) 
 as! NSDictionary as! [String:

    AnyObject] • Swift ʹ͓͚Δ࿈૝഑ྻʹม׵
  91. +40/Λύʔε try! NSJSONSerialization.JSONObjectWithData(data!, 
 options:NSJSONReadingOptions.MutableContainers) 
 as! NSDictionary as! [String:

    AnyObject] • ྫ֎Λແࢹ
  92. σʔλอ࣋Ϋϥε

  93. σʔλอ࣋Ϋϥε w ฦ͖ͬͯͨ+40/ΛಡΈࠐΈɺΫϥεʹ֨ೲ͢Δ w σʔλΛѻ͍΍͘͢͢ΔͨΊ

  94. σʔλอ࣋Ϋϥε • Question ΫϥεΛ࡞Δ • Question.swift Λ࡞੒

  95. import Foundation class Question { let isAnswered: Bool let ownerName:

    String let upVoteCount: Int let tags: [String] init(dict: [String: AnyObject]) { isAnswered = 
 dict["is_answered"] as! Bool upVoteCount = 
 dict["up_vote_count"] as! Int title = dict[“title"] as! String let owner = dict["owner"]
 as! [String: AnyObject] ownerName = owner["display_name"] as! String } }
  96. import Foundation class Question { let isAnswered: Bool let ownerName:

    String let upVoteCount: Int let tags: [String] init(dict: [String: AnyObject]) { isAnswered = 
 dict["is_answered"] as! Bool upVoteCount = 
 dict["up_vote_count"] as! Int title = dict[“title"] as! String let owner = dict["owner"]
 as! [String: AnyObject] ownerName = owner["display_name"] as! String } }
  97. import Foundation class Question { let isAnswered: Bool let ownerName:

    String let upVoteCount: Int let tags: [String] init(dict: [String: AnyObject]) { isAnswered = 
 dict["is_answered"] as! Bool upVoteCount = 
 dict["up_vote_count"] as! Int title = dict[“title"] as! String let owner = dict["owner"]
 as! [String: AnyObject] ownerName = owner["display_name"] as! String } }
  98. KTPOΛ2VFTUJPOʹม׵ let dict = try! NSJSONSerialization.JSONObjectWithData(…)
 as! NSDictionary as! [String:

    AnyObject] let questions = (dict["items"] as! [[String: AnyObject]]).map{ item -> Question in Question(dict: item) }
  99. RVFTUJPOT<>ͷUJUMFΛग़͢

  100. ᶆॲཧͨ݁͠ՌΛදࣔ

  101. 5BCMF7JFX ಉ͡7JFXΛ܁Γฦ͠Ϧετදࣔ͢Δ7JFX

  102. ී௨ʹ্͔ΒViewΛஔ͚͹͍͍͡ΌΜʁ

  103. w ⚠ཁૉ͕ݸҎ্ʹͳΔ͜ͱ΋ w ྫ5XJUUFS w ͜ͷ࣌ݸಉ࣌ʹViewΛอ࣋ɾ؅ཧ͢Δʁ
 ˠ๲େͳϝϞϦɾॲཧΛফඅͯ͠͠·͏ 5BCMF7JFX

  104. w Ϧετදࣔ͸ಉ͡ߏ଄ͷView͕࿈ͳΔ w จࣈྻ౳ͷ಺༰͕ҧ͏͚ͩ ˠɹอ࣋ɾ؅ཧ͸ը໘ʹදࣔ͞ΕΔViewͷΈ ˠɹҰ౓࡞ͬͨView͸࠶ར༻͠ɺ
 දࣔ࣌ʹ಺༰Λมߋ͢Δ 5BCMF7JFX

  105. w ͢΂ͯΛอ࣋ɾ؅ཧ ී௨ͷ7JFX View 1 2 3 4 5 6

    7 8 9 10 11 12 13 14 15 16 17 18 ࣮ࡍͷදࣔྖҬ →
  106. w อ࣋ɾ؅ཧ͸ը໘্ͷΈ 5BCMF7JFX TableView 3 4 5 6 7 8

    9 10 11 ະੜ੒ ࣮ࡍͷදࣔྖҬ →
  107. εΫϩʔϧ͞ΕΔͱʜ TableView 3 4 5 6 7 8 9 10

    11 ະੜ੒ View ͷ࠶ར༻ දࣔྖҬ →
  108. εΫϩʔϧ͞ΕΔͱʜ View 5 6 7 8 9 10 11 3

    ->12 4 ->13 ະੜ੒ ← ৽͍͠஋Λઃఆ දࣔྖҬ →
  109. 

  110. Ϧετදࣔ ߲໨ͷViewΛ࡞੒ ˣ TableViewʹදࣔ

  111. ߲໨ͷ7JFX $FMM

  112. ࡞Γ·ͨ͠

  113. *EFOUJpFSΛઃఆ w TableView͕CellΛ۠ผ͢Δͷʹඞཁ

  114. w 2VFTUJPO5BCMF7JFX$FMMΛ࡞੒ w $FMMΛಠࣗΫϥεʹͯ͠؅ཧ $VTUPN7JFXΫϥε import UIKit class QuestionTableViewCell: UITableViewCell

    { }
  115. $VTUPN7JFXʹඥ෇͚

  116. $FMM಺ͷ7JFXΛඥ෇͚

  117. $FMM಺ͷ7JFXΛඥ෇͚ import UIKit class QuestionTableViewCell: UITableViewCell { @IBOutlet weak var

    countLabel: UILabel! @IBOutlet weak var checkImageView: UIImageView! @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var tagLabel: UILabel! @IBOutlet weak var bodyLabel: UILabel! @IBOutlet weak var dateLabel: UILabel! @IBOutlet weak var authorLabel: UILabel! }
  118. 2VFTUJPOઃఆͰ6*ߋ৽ class QuestionTableViewCell: UITableViewCell { @IBOutlet weak var countLabel: UILabel!

    … var question: Question? { didSet { bindQuestion(question!) } } private func bindQuestion(question: Question) { countLabel.text = String(question.upVoteCount) checkImageView.hidden = !question.isAnswered … } } Setter
  119. 5BCMF7JFXʹදࣔ

  120. class MainViewController: UIViewController, UISearchBarDelegate, 
 UITableViewDelegate, UITableViewDataSource { @IBOutlet weak

    var searchBar: UISearchBar! @IBOutlet weak var questionTableView: UITableView! override func viewDidLoad() { super.viewDidLoad() searchBar.delegate = self questionTableView.dataSource = self questionTableView.delegate = self } } w Delegate Λ࣮૷ 5BCMF7JFX
  121. class MainViewController: UIViewController, UISearchBarDelegate, 
 UITableViewDelegate, UITableViewDataSource { @IBOutlet weak

    var searchBar: UISearchBar! @IBOutlet weak var questionTableView: UITableView! override func viewDidLoad() { super.viewDidLoad() searchBar.delegate = self questionTableView.dataSource = self questionTableView.delegate = self } } w UITableViewDelegateΫϦοΫ͞Εͨ࣌ͱ͔ w UITableViewDataSourceσʔλ͔Β$FMMΛ࡞Δ࣌ 5BCMF7JFX
  122. • εΫϩʔϧͯ͠ Cell Λ࡞੒͢Δͱ͖ʹݺ͹ΕΔ • ৔ॴ͕Ҿ਺ͱͯ͠དྷΔ $FMMΛ࡞Δ func tableView(tableView: UITableView,

    cellForRowAtIndexPath 
 indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("questionCell",
 forIndexPath: indexPath) as! QuestionTableViewCell cell.question = self.questions[indexPath.row] return cell }
  123. • ઌ΄Ͳࢦఆͨ͠ Identifier ΛೖΕͯ
 ࠶ར༻Մೳͳ Cell ΛಘΔ • ͳ͚Ε͹ࣗಈͰ࡞ͬͯ͘ΕΔ $FMMΛ࡞Δ

    func tableView(tableView: UITableView, cellForRowAtIndexPath 
 indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("questionCell",
 forIndexPath: indexPath) as! QuestionTableViewCell cell.question = self.questions[indexPath.row] return cell }
  124. func tableView(tableView: UITableView, cellForRowAtIndexPath 
 indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("questionCell",
 forIndexPath: indexPath) as! QuestionTableViewCell cell.question = self.questions[indexPath.row] return cell } • ಘΒΕͨ Cell ͸ QuestionTableViewCell $FMMΛ࡞Δ
  125. func tableView(tableView: UITableView, cellForRowAtIndexPath 
 indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("questionCell",
 forIndexPath: indexPath) as! QuestionTableViewCell cell.question = self.questions[indexPath.row] return cell } • อ͍࣋ͯ͠Δ Question Λ cell ʹηοτ $FMMΛ࡞Δ
  126. w ηΫγϣϯͷ਺ • Cell ͷ਺ 5BCMF7JFXͷઃఆ func numberOfSectionsInTableView(tableView: 
 UITableView)

    -> Int { return 1 } func tableView(tableView: UITableView, 
 numberOfRowsInSection section: Int) -> Int { return self.questions.count }
  127. 5BCMF7JFXͷߋ৽ let dict = try! NSJSONSerialization.JSONObjectWithData(…)
 as! NSDictionary as! [String:

    AnyObject] self.questions = (dict["items"] as! [[String: AnyObject]]).map{ item -> Question in Question(dict: item) } self.questionTableView.reloadData() w tableViewʹσʔλͷߋ৽Λ఻͑Δ w ͜ΕͰCell͕࠶ಡΈࠐΈ͞ΕΔ
  128. ΫϦοΫͯ͠4BGBSJΛ։͘ w tableViewͷCellΛΫϦοΫͨ࣌͠ʹݺ͹ΕΔ w CellΛ࡞Δؔ਺ͱ͸֎෦Ҿ਺໊͕ҧ͏ func tableView(tableView: UITableView, didSelectRowAtIndexPath 


    indexPath: NSIndexPath) { let question = questions[indexPath.row] let url = NSURL(string: question.link)! UIApplication.sharedApplication().openURL(url) }
  129. w indexPath͔ΒQuestionΛऔಘ w question.linkΛSafariͰ։͘ ΫϦοΫͯ͠4BGBSJΛ։͘ func tableView(tableView: UITableView, didSelectRowAtIndexPath 


    indexPath: NSIndexPath) { let question = questions[indexPath.row] let url = NSURL(string: question.link)! UIApplication.sharedApplication().openURL(url) }
  130. ΞϓϦΛىಈ

  131. https://gyazo.com/d34d8f4caf0a48e1855c865cf1772748

  132. ײ૝ w J04ྑ͍ w 4XJGU͸࠷ߴ w όʔδϣϯݹ͍ͷʹରԠ͠ͳͯ͘ྑ͍ w Ϗϧυૣ͍

  133. ײ૝ w J04ͭΒ͍ w 0CKFDUJWF$ͷίʔυ͕ಡΊͳ͍ͱݫ͍͠ w ϥΠϒϥϦɾ4UBDL0WFS'MPX w υϥοάຖճ͢Δͷ໘౗ w

    9DPEF͕Α͘མͪΔʢىಈ͸ૣ͍ʣ
  134. ͋Γ͕ͱ͏͍͟͝·ͨ͠

  135. "OESPJEฤ͸ͪ͜Β