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

Swift on a Deadline

Orta
November 13, 2014

Swift on a Deadline

Trying to pull off a complex swift app on a deadline.

Meant to work well with this blog post: http://artsy.github.io/blog/2014/11/13/eidolon-retrospective/

Orta

November 13, 2014
Tweet

More Decks by Orta

Other Decks in Programming

Transcript

  1. Obj-C // // main.m // snapshots // // Created by

    orta therox on 15/12/2007. // Copyright __MyCompanyName__ 2007 . All rights reserved. // @orta
  2. Overloading public func ==(lhs: UIStoryboardSegue, rhs: SegueIdentifier) -> Bool {

    return lhs.identifier == rhs.rawValue } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue == .ShowSaleArtworkDetails { let saleArtwork = sender as SaleArtwork! ... } } @orta
  3. Lazy lazy var keypadSignal:RACSignal! = self.keypadContainer.keypad?.keypadSignal lazy var clearSignal:RACSignal! =

    self.keypadContainer.keypad?.rightSignal lazy var deleteSignal:RACSignal! = self.keypadContainer.keypad?.leftSignal lazy var provider:ReactiveMoyaProvider<ArtsyAPI> = Provider.sharedProvider @orta
  4. Clo-uncs func isZeroLengthString(string:AnyObject!) -> AnyObject! { return countElements(string as String)

    == 0 } ... let numberIsInvalidSignal = RACObserve(bidDetails.newUser, "phoneNumber").map(isZeroLengthString) RAC(confirmButton, "enabled") <~ numberIsInvalidSignal.notEach() @orta
  5. Inline @IBOutlet var bidButton: Button! @IBAction func bidButtonTapped(sender: AnyObject) {

    let identifier = hasAlreadyPlacedABid ? SegueIdentifier.PlaceAnotherBid : SegueIdentifier.ConfirmBid performSegue(identifier) } @orta
  6. In just six months, Swift’s high performance and clean syntax

    have made it the most popular way to find out that SourceKitService Terminated — @Horse_iOS // https://twitter.com/Horse_iOS/status/533027167488454656 @orta
  7. There is so much you cannot do with Swift, my

    code is littered with @objc. NSObject and a whole load more legacy #SwiftLang — @ColinEberhardt - ( Shinobi Controls ) // https://twitter.com/ColinEberhardt/status/ 531506177180700673 @orta
  8. I started looking at Swift today and I've restarted the

    playground at least 20 times in the past hour. Hard to get excited about this… — @chockenberry - ( Twitteriffic.app ) // https://twitter.com/chockenberry/status/ 532270455537692672 @orta
  9. I’m getting multiple SourceKitService crashed for every(!) line I write

    in this Swift project. This stuff is far from ready… — @pieteromvlee - ( Sketch.app ) [^om] // https://twitter.com/pieteromvlee/status/ 531534471708020736 @orta
  10. For all the crap I give #swift, the syntax is

    still much nicer than ObjC. Hopefully the expressiveness of ObjC is brought quickly. — @owensd - ( MS Office ) // https://twitter.com/owensd/status/524972593774743553 @orta
  11. func waitForBidResolution () -> RACSignal { return self.pollForUpdatedSaleArtwork().then { [weak

    self] (_) in return self == nil ? RACSignal.empty() : self!.checkForMaxBid() } .doNext { _ in self.bidIsResolved = true return // If polling fails, we can still show bid confirmation. Do not error. } .catchTo( RACSignal.empty() ) } src @orta
  12. bidderNetworkModel.createOrGetBidder().doError { (error) -> Void in self.bidderError() } .then {

    if !self.placingBid { ARAnalytics.event("Registered New User Only") return RACSignal.empty() } ARAnalytics.event("Started Placing Bid") return self.placeBid() } .then { [weak self] (_) in if self == nil { return RACSignal.empty() } self?.bidCheckingModel = self?.bidCheckingModel ?? self?.createBidCheckingModel() if self?.placingBid == false { return RACSignal.empty() } return self!.bidCheckingModel.waitForBidResolution() } .subscribeCompleted { [weak self] (_) in self?.finishUp() return } src @orta