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

Swift 4.0 対応しようとしたら大変な目に遭った話

Elvis Shi
September 16, 2017

Swift 4.0 対応しようとしたら大変な目に遭った話

Swift 4対応するときのエモい話

Elvis Shi

September 16, 2017
Tweet

More Decks by Elvis Shi

Other Decks in Programming

Transcript

  1. override init() { super.init() emplyedBy = "MAGES. 5pb. Game div"

    job = "iOS Developer" twitter = "@lovee" qiita = "@lovee" github = "el-hoshino" additionalInfo = "དྷ݄స৬͠·͢ʘ(^o^)ʗ" class Speaker: Developer { } }
  2. &MUBTPͱ͸Կ͔ ▸ 4XJGUʹ͋Γͦ͏Ͱͳ͔ͬͨ৭ΜͳศརͳػೳΛ੝ΓࠐΜͩ൚༻ϑϨʔϜϫʔΫ ▸ CGPointಉ࢜ͳͲͷ଍͠ࢉҾ͖ࢉ ▸ ܾ·ͬͨൣғ಺ͷཚ਺ੜ੒Int.makeRandom(within: 0 ..< 10)

    ▸ ഑ྻͷγϟοϑϧ[1, 2, 3, 4, 5].shuffled ▸ ͳͲͳͲʜ ▸ ࠷ॳ͸ϋοΧιϯͷ࣌ͷίʔσΟϯάޮ཰ͷͨΊʹ࡞ͬͨ ▸ ࡞ͬͯΔ͏ͪʹʮ࣮຿ʹ΋ศར͡ΌͶʯͱࢥͬͯ࢖͍࢝Ίͨ IUUQTHJUIVCDPNFMIPTIJOP&MUBTP
  3. &MUBTPͷԿ͕มΘ͔ͬͨ ▸ ͿͬͪΌ͚࡞ͬͨ౰ॳ͸Կ΋ਂ͘ߟ͑ͣʹػೳ੝ΓࠐΜͰͨ ▸ 4XJGUˠͷ࣌ͷίʔυमਖ਼͚ͩͰେมͩͬͨͷͰͦΕʹઐ೦ͨ͠ ▸ 4XJGUˠͷࠓ͸ίʔυमਖ਼΄΅ͳ͔ͬͨͷͰʮ༨ܭʯͳ͜ͱߟ͑࢝Ίͨ ▸ ͜ͷ"1*ઃܭ͸ຊ౰ʹެࣜΨΠυϥΠϯʹଇͬͯΔ͔Ͳ͏͔ ▸

    ͜Ε͸ຊ౰ʹ&MUBTPʹೖΕΔ΂͖ػೳ͔ʢಠཱͤ͞Δ΂͖͔ʣ ▸ 5BSHFUFE&YUFOTJPOTͷಋೖʢxxx.rx.doSth()Έ͍ͨͳॻ͖ํʣ ▸ ࢖͍ํ͕ΨϥϦͱมΘͬͯ&MUBTPґଘͷϓϩδΣΫτ͕େมͳ͜ͱʹ IUUQTHJUIVCDPNFMIPTIJOP&MUBTP
  4. /PU"VUP-BZPVUΛ৽ͨʹಋೖͨ͠ ▸ ౰ॳ΋શͯͷϨΠΞ΢τ͸ίʔυϕʔεͩͬͨ ▸ ϨΠΞ΢τ͸શͯlayoutSubviews()ͷoverrideͰରԠͨ͠ ▸ ೝ͕ࣝ଍Γͣɺ௚઀layoutSubviews()Λݺͼग़͢Օॴ΋͋ͬͨ ▸ ࢠϏϡʔΛϓϩύςΟʔͱͯ͠อ࣋͢Δඞཁ͕͋ͬͨ ▸

    ผͷϓϩδΣΫτͷ੍࡞࣌ʹ/PU"VUP-BZPVUΛ࡞ͬͨ ▸ layoutSubviews()Λඞͣ͠΋override͢Δඞཁ͕ͳ͘ͳͬͨ ▸ ࢠϏϡʔͷϨΠΞ΢τΛ਌ϏϡʔͷϓϩύςΟʔͱͯ͠อ࣋Ͱ͖ΔͨΊ
 ࢠϏϡʔࣗମΛϓϩύςΟʔͱͯ͠อ࣋͢Δඞཁ͕ͳ͘ͳͬͨ ▸ ʲએ఻ʳචऀݱࡏͷϝΠϯ044ϓϩδΣΫτʂ IUUQTHJUIVCDPNFMIPTIJOP/PU"VUP-BZPVU
  5. FlowContentControllerʢچʣ fileprivate lazy var chapterButtons: [FlowChapterButton] = { let chapters

    = GlobalSettings.shared.chapterMetas let buttons = chapters.enumerated().map { (i, chapterMeta) -> FlowChapterButton in let button = FlowChapterButton(meta: chapterMeta) button.setOnTappedAction({ [weak self] _ in self?.didSelectChapter(i) }) return button } return buttons }()
  6. FlowContentControllerʢ৽ʣ private lazy var chapterButtons: [FlowChapterButton] = { let chapters

    = self.model.getChapters(for: self) let buttons = chapters.map { (chapter) -> FlowChapterButton in let button = self.makeButton(for: chapter) return button } return buttons }()
  7. FlowControllerʢچʣ override func viewDidLoad() { super.viewDidLoad() // Do any additional

    setup after loading the view. do { let controller = self.flowContentController controller.delegate = self controller.dataSource = self.dataSource self.addChildViewController(controller) self.flowView.contentView = controller.view controller.didMove(toParentViewController: self) } do { let controller = self.pageHeaderController controller.setHeaderTitleString("νϟϓλʔબ୒") self.addChildViewController(controller) self.flowView.header = controller.view controller.didMove(toParentViewController: self) } }
  8. ॳ৺ऀ΁ͷΞυόΠε ▸ ͱʹ͔͕͘Ή͠ΌΒʹ͍ͬͺ͍ॻ͖·͠ΐ͏ɻ ▸ Կ΋ߟ͑ͣʹॻ͘ͷͰ͸ͳ͘ɺྫ͑)PX͕ཧղͰ͖ͳͯ͘΋ɺ8IBUͱ8IZ Λཧղ͢Δ౒ྗΛ͠·͠ΐ͏ɻ ▸ ΍Γ͍ͨ͜ͱ͕Ͱ͖͔ͨΒͬͯࢥߟఀࢭͤͣɺΑΓྑ͍ॻ͖ํ͕ͳ͍͔΋ߟ͑· ͠ΐ͏ɻ ▸

    ͍ͬͺ͍นʹͿ͔ͭͬͯઃܭʹ͍ͭͯͷཧղΛਂΊ·͠ΐ͏ɻ ▸ 2JJUB΍5FSB5BJM΋ྑ͍Ͱ͕͢ɺެࣜυΩϡϝϯτ΋ͪΌΜͱಡΈ·͠ΐ͏ɻ ▸ ൒೥લͷࣗ෼͕ॻ͍ͨίʔυ͕ΫιͩͱࢥΘͳ͔ͬͨΒ੒௕͕ࢭ·ͬͨূڌʂ