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

API Design in Swift

API Design in Swift

Avatar for FUJI Goro

FUJI Goro

June 20, 2014
Tweet

More Decks by FUJI Goro

Other Decks in Programming

Transcript

  1. API Design In Swift #WWDCPAD FUJI Goro (@__gfx__), a software

    engineer in COOKPAD WWDC2014 reports at COOKPAD, 2014/6/20
  2. FUJI Goro (@__gfx__) • Software engineer @ COOKPAD Inc. •

    Development common libraries for Android / iOS
  3. ϝιουݺͼग़͠ߏจ • Objective-C: [[receiver method1] method2] • Swift: receiver.method1().method2() •

    ϝιουνΣΠϯ͕΍Γ΍͍͢ • ࠷ޙͷҾ਺͕ؔ਺ܕͩͱಛघͳߏจ͋Γ • “trailing closures” • receiver.method() { params-> Type in … }
  4. Example func dispatch_async(queue: dispatch_queue_t!, block: dispatch_block_t!) ! // trailing closures

    (຤ඌΫϩʔδϟʣ ! dispatch_async(dispatch_get_main_queue()) { NSLog(“foo”) } ! // ௨ৗͷߏจͰ΋࢖͑Δ ! dispatch_async(dispatch_get_main_queue(), { NSLog("foo") }) !
  5. Show Notes • Welcome Swift • The Swfit Programming Language

    • Using Swift with Cocoa and Objective-C