Slide 1

Slide 1 text

ը໘ભҠͱࢲʢiOSʣ ॴ ༑ଠ @tokorom iOS App Programer potatotips-19

Slide 2

Slide 2 text

ॴ༑ଠ @tokorom

Slide 3

Slide 3 text

ͪΐ͏Ͳ1೥લ ୈ6ճ potatotips

Slide 4

Slide 4 text

iOSͷը໘ભҠͱࢲ ॴ ༑ଠ @tokorom iOS App Programer potatotips-19

Slide 5

Slide 5 text

ը໘ભҠͷྺ࢙

Slide 6

Slide 6 text

ը໘ભҠͷྺ࢙ •لݩલɿStoryboardొ৔લ •لݩޙɿStoryboardొ৔Ҏޙ •৽࣌୅ɿcontext࣌୅ʁ

Slide 7

Slide 7 text

Storyboardొ৔Ҏલͷը໘ભҠ let selectVC = SelectItemVC() selectVC.targetUser = self.user self.presentViewController(selectVC, animated: true, completion: nil) ભҠઌʹ஋Λ౉͢

Slide 8

Slide 8 text

Storyboardొ৔Ҏલͷը໘ભҠ selectVC.delegate = self extension MyViewController: SelectItemVCDelegate { override func itemDidSelect(item: Item) { // get an item! } } ભҠઌ͔Β஋Λ΋Β͏

Slide 9

Slide 9 text

Storyboard࣌୅ͷը໘ભҠ self.performSegueWithIdentifier("SelectItems", sender: nil) override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { switch segue.identifier { case: "SelectItems": if let selectVC = segue.destinationViewController as? SelectItemsViewController { selectVC.user = self.user } ભҠઌʹ஋Λ౉͢

Slide 10

Slide 10 text

Storyboard࣌୅ͷը໘ભҠ @IBAction func unwind(segue: UIStoryboardSegue) { if let vc = segue.sourceViewController as? SelectitemVC { let item = vc.selectedItem } } ભҠઌ͔Β஋Λ΋Β͏

Slide 11

Slide 11 text

WatchKitͰͷྫ self.presentControllerWithName("SelectItem", context: user) override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) self.user = context as? User } ભҠઌʹ஋Λ౉͢

Slide 12

Slide 12 text

WatchKitͰͷྫ self.presentControllerWithName("SelectItem", context: user) override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) self.user = context as? User } ભҠઌʹ஋Λ౉͢

Slide 13

Slide 13 text

WatchKitͷcontextͷྑ͍ͱ͜Ζ •ૄ݁߹ʂ •஋Λ౉͢ͱ͖ʹભҠݩͱભҠઌ͕ґଘؔ܎͕Ͱ ͖ͳ͍ •ಉ͡ΠϯλʔϑΣʔεͰͳΜͰ΋౉ͤΔ •Optional BidingͳͲͰ؆୯/҆શʹड͚औΕΔ

Slide 14

Slide 14 text

ͳ͓… ̍ϲ݄લͷ΅͘

Slide 15

Slide 15 text

Swift࣌୅͸ΈΜͳ͜͏ॻ͖͍ͨΑͶ self.performSegueWithIdentifier("ItemSelect", context: user) { (item: Item) in let selectedItem = item } ભҠઌʹ஋Λ౉͢ˍ΋Β͏

Slide 16

Slide 16 text

ͪΐ͏Ͳ1೥લ ୈ6ճ potatotips

Slide 17

Slide 17 text

ͪΐ͏Ͳ1೥લ ୈ6ճ potatotips

Slide 18

Slide 18 text

ͦͯ͠ࠓ೔ʂ https://github.com/tokorom/SegueContext

Slide 19

Slide 19 text

͜ͷॻ͖ํɺͰ͖·͢ʂ self.performSegueWithIdentifier("ItemSelect", context: user) { (item: Item) in let selectedItem = item } ભҠઌʹ஋Λ౉͢ˍ΋Β͏

Slide 20

Slide 20 text

UIViewController+Contextͷྑ͍ͱ͜ •ૄ݁߹ʂ •SwiftͰܕ҆શͳ஋ͷड͚౉͠ •NavigationControllerͱ͔TabBarControllerΛڬΜ Ͱ΋΁ͬͪΌΒ •ΧελϜSegueͳͲෳࡶͳભҠͰ΋࢖͑Δ •Apple Way͔Β͸ͣΕ͗͢ͳ͍ʁ

Slide 21

Slide 21 text

More Information Yuta ToKoRo iOS App Programer Twitter @tokorom http://www.tokoro.me/ https://github.com/tokorom/SegueContext