古き良きsendAction (in potatotips #26)
by
tokorom
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
ݹ͖ྑ͖ sendAction ॴ ༑ଠ @tokorom iOS App Programer potatotips-26
Slide 2
Slide 2 text
ॴ༑ଠ @tokorom (ϑϦʔλʔʣ potatotipsӡӦ૭ޱ / potatotipsΛओ࠵͍͚ͨͩΔձࣾ͞Μืूதʂ
Slide 3
Slide 3 text
UIApplication - sendAction
Slide 4
Slide 4 text
UIApplication - sendAction •࣮ࡍʹ͍ͬͯΔਓͲͷ͘Β͍ʁ •ͦͦଘࡏΛ͍ͬͯΔʁ •ʢUIControlͷ΄͏ͨ·ʹݟΔ͚Ͳ…ʣ •ʢ͍ͬͯΔͷΛ͋Μ·Γݟͨ͜ͱͳ͍ʣ
Slide 5
Slide 5 text
UIApplication - sendAction NEW! iOS 9 Ͱ ྲྀ ͷ͝ͱ͘ݱΕͨ ࠷ڧ ͷ function !?
Slide 6
Slide 6 text
UIApplication - sendAction iPhone OS 2 ͔Β ͘͝ ී௨ ʹଘࡏ͢Δ ͋·Γ ΘΕͳ͍ ͭ
Slide 7
Slide 7 text
// hoge: ΛൃՐ let app = UIApplication.sharedApplication() app.sendAction("hoge:", to: xxx, from: sender, forEvent: nil) // hoge: func hoge(sender: AnyObject) { print("hoge!!") } αϯϓϧίʔυ UIApplication - sendAction
Slide 8
Slide 8 text
UIApplication - sendAction •ग़ͨΑɺจࣈྻࢦఆʂ •Objective-C෩selectorࢦఆ͕ݹष͍ •͍ॴ͋Δͷʁ •RxSwiftͱ͔͏΄͏͕Α͘ͳ͍ʁ app.sendAction("hoge:", to: xxx, from: sender, forEvent: nil) ͓͓ΉͶ ਖ਼ղ
Slide 9
Slide 9 text
Responder Chain (in UIKit)
Slide 10
Slide 10 text
Responder Chain (in UIKit) •Ԟ·ͬͨ֊ͰൃՐ •֊ͷͲ͜Ͱड͚ΒΕΔ •DelegateͷΑ͏ʹreceiverΛड͚ ͢ඞཁ͕ͳ͍ •ଞखஈͰಉ͡ߏΛ࣮ݱ͢Δͷ ͍͠
Slide 11
Slide 11 text
Responder Chain (in UIKit) app.sendAction("hoge:", to: xxx, from: sender, forEvent: nil) app.sendAction("hoge:", to: , from: sender, forEvent: nil) app.sendAction("hoge:", to: nil, from: sender, forEvent: nil)
Slide 12
Slide 12 text
Responder Chain (in UIKit) UITabBarController UIViewController UITabBarController UIViewController UIViewController UIViewController
Slide 13
Slide 13 text
Responder Chain (in UIKit) UITabBarController UIViewController UITabBarController UIViewController UIViewController UIViewController UITableView UITableViewCell UIView UIButton
Slide 14
Slide 14 text
sendActionͷྑ͍ͱ͜Ζ •Responder Chainͳૄ݁߹ͳΈͰը໘ߏ ͕มΘͬͯར༻Ͱ͖Δ •CocoaͷࠜװͱͳΔΈͷͨΊྲྀߦʹࠨӈ͞ Εͳ͍
Slide 15
Slide 15 text
sendActionͷμϝͳͱ͜Ζ •ΠϯλʔϑΣʔε͕ݹ͍ •จࣈྻࢦఆ •selector?? •ҾʹಛఆͷObjectΛͮ͠Β͍
Slide 16
Slide 16 text
৽͍͠ΠϯλʔϑΣʔεͰϥοϐϯά // hoge: ΛൃՐ HogeEvent(hoge: hoge).fireFrom(self.view) // hoge: func hoge(sender: AnyObject) { guard let hoge: Hoge =ɹContext.valueFor(sender) else { return } print("hoge: \(hoge)") }
Slide 17
Slide 17 text
·ͱΊ •UIApplicationͷsendAction߹ʹΑͬͯ༗ ༻ •ݹ͖ྑ͖ػೳ͕ͩը໘ߏ͕ෳࡶͳݱͰͦ͜ ར༻Ձ͕͋Δ •ੲ͔Β͋Δػೳʹҙ֎ͱ͑Δͷ͕ͬͯ ͍Δ͔ʁ
Slide 18
Slide 18 text
More Information Yuta ToKoRo iOS App Programer Twitter @tokorom http://www.tokoro.me/