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

ReactiveCocoa Tokyo LT

huin
October 18, 2014
16

ReactiveCocoa Tokyo LT

2014/10/18(土)に五反田の株式会社freeeさんで行われた勉強会[「Reactive Cocoa Tokyo」](http://connpass.com/event/8680/)のLTで発表した内容です

※ 公開用に修正しています。

huin

October 18, 2014
Tweet

Transcript

  1. ࣗݾ঺հ • @huin • blog.huin.me • Work at : 


    - VOYAGE GROUP
 - genesix, Inc. • iOSྺ3೥͘Β͍
  2. // Objective-C - (BFTask *) fetchAsync:(PFObject *)object { BFTaskCompletionSource *task

    = [BFTaskCompletionSource taskCompletionSource]; [object fetchInBackgroundWithBlock:^(PFObject *object, NSError *error) { if (!error) { [task setResult:object]; } else { [task setError:error]; } }]; return task.task; }
  3. // Objective-C - (void) doSomething { BFTask *task = [self

    fetchAsync:self.object]; [task continueWithBlock:^id(BFTask *task) {
 if (task.error) { // handle error }else{ // do post fetch task… } return task; }]; }
  4. 1.ॲཧͷϦετ 1. ϩΰͷग़ݱΞχϝʔγϣϯ 2. Ϣʔβʔొ࿥(if required) 3. ͓ؾʹೖΓͷऔಘ 4. ϩΰͷඇදࣔΞχϝʔγϣϯ

    5. ࣍ͷը໘΁ͷભҠ a. ࣮ߦॱং a. 2→3͸ඇಉظॲཧΛॱ൪ʹ࣮ߦ b. 1ͱλεΫa͸ฒྻʹॲཧ͢Δ
 (λεΫb) c. λεΫaͱbͷ஗͍ํΛ
 λεΫbͷ׬ྃͱ͢Δ d. λεΫb͕׬ྃͨ͠Β
 4Λ։࢝͢Δ e. 4͕׬ྃͨ͠Β5Λ࣮ߦ
  5. // λεΫ(1) : ϩΰͷදࣔΞχϝʔγϣϯ BFTask *welcomeTask = [self showAnimationTask]; !

    // λεΫ(2) : Ϣʔβʔొ࿥ BFTask *userTask = [[self saveUserTask] continueWithBlock:^id(BFTask *task) { if (task.error) { return task; } // λεΫ(3) ͓ؾʹೖΓͷऔಘ. λεΫ(2)ͷޙʹ࣮ߦ͞ΕΔ. return [self fetchFavoriteTask]; }]; ! // λεΫ(b) : λεΫ(1)ͱλεΫ(a)ͷ̎ͭΛฒྻʹॲཧ͢Δ BFTask *tasks = [BFTask taskForCompletionOfAllTasks:@[welcomeTask, userTask]]; ! [[tasks continueWithSuccessBlock:^id(BFTask *task) { ! // λεΫ(4) : ϩΰͷඇදࣔΞχϝʔγϣϯ. λεΫ(b)׬ྃޙʹ࣮ߦ͞ΕΔ. return [self hideAnimationTask]; }] continueWithBlock:^id(BFTask *task) { if (task.error) { [UIAlertView alertWithError:task.error]; }else{ // λεΫ(5) : ࣍ͷը໘΁ͷભҠ [self segueToNextView]; } return task; }];
  6. • ωοτϫʔΫॲཧ͚ͩʹݶΒͣ࢖͍υίϩ͸͋Δ͔ ΋. • ΋ͬͱΞχϝʔγϣϯڽͬͯ΋ྑ͍͔΋
 (ྫ : ΞχϝʔγϣϯදࣔͷϓϩάϨεόʔΛͲ͏͢Ε͹ମײ଎౓͕Ξοϓ͢Δͷ͔͕൑໌ | GIGAZINE

    http://goo.gl/6EaJQe) • ͝ར༻͸ܭըతʹ
 (ඇಉظॲཧ͢΂ͯͰBolts࢖͏΂͖ʁ) • ※ Bolts-iOSͰ͋Δඞཁ͸ͳ͍ͷͰ޷͖ͳϥΠϒϥϦͰ ॻ͚͹͍͍Α!!