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

実践RubyMotion

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

 実践RubyMotion

RubyMotion Kaigi 2013 での発表資料です

Avatar for Naoya Ito

Naoya Ito

May 29, 2013
Tweet

More Decks by Naoya Ito

Other Decks in Technology

Transcript

  1. class  HelloViewController  <  UIViewController      def  viewDidLoad    

         super            self.view.backgroundColor  =  UIColor.whiteColor            @label  =  UILabel.new          @label.frame  =  [[10,  10,],  [320,  20]]          @label.text    =  "Hello,  World!”            self.view.addSubview(@label)      end   end
  2. Ώ͑ʹ •  ී௨ʹ3VCZͱͯ͠ॻ͚Δ UILabel.new.tap  do  |label|      label.text  =

     "Hello,  World!"   end     •  $PDPBͷ"1*͕ݺ΂Δ self.willChangeValueForKey('bookmarks')   ...   self.didChangeValueForKey('bookmarks')  
  3. ฒߦॲཧ΋͓खͷ΋ͷ •  (SBOE$FOUSBM%JTQBUDI Dispatch::Queue.concurrent.async  do      image  =  UIImage.alloc.initWithData(

             NSData.dataWithContentsOfURL(url.nsurl)      )        Dispatch::Queue.main.sync  do          @imageView.image  =  image      end   end  
  4. ϝϞϦ؅ཧ •  3VCZ.PUJPOಠࣗͷϝϞϦ؅ཧ࣮૷ –  OPU"3$ –  OPU3VCZT($ •  ϦϑΝϨϯεΧ΢ϯλํࣜ – 

    "3$෩ʹࣗಈͰBHFTBHF –  8FBL3FGFSFODF͋Γ 3VCZ.PUJPO͔Β  –  ʮ1FSMΈ͍ͨͳ΋ͷͩͱࢥ͑͹ྑ͍ʯʮ͑ͬʯ
  5. #  Rakefile   require  'rubygems'   require  'sugarcube'   navigationController

     <<  WebViewController.new.tap  do  |c|      c.url  =  'http://example.com'   end  
  6. #VCCMF8SBQ #  Asynchronous  HTTP   BW::HTTP.get("https://api.github.com/users/mattetti")  do  |response|    

     p  response.body.to_str   end   #  Timer   timer  =  EM.add_periodic_timer  1.0  do      count  =  count  +  1      (count  <  10)  ||  EM.cancel_timer(timer)   end   #  Observers   include  BW::KVO   observe(@label,  :text)  do  |old_value,  new_value|      ...   end  
  7. 4VHBSDVCF #  navigationController.pushViewController(c,  animated:true)   navigationController  <<  c   #

     self.view.addSubView(@label)   self.view  <<  @label   #  UIButton.buttonWithType(UIButtonTypeRoundedRect)   UIButton.rounded_rect   #  button.addTarget(self,  action:'ButtonDidPush',  forControlEvents:UIControlEventTouchUpInside)   button.on(:touch)  do      ...   end  
  8. NPUJPOTVQQPSU #  motion-­‐support/core_ext/time   1.weeks.ago   17.days.from_now   #  motion-­‐support/inflector

      "app_delegate".camelize   "thing".pluralize   #  motion-­‐support/core_ext/object   nil.blank?   1.try(:to_s)  
  9. /BOP4UPSF*O.PUJPO class  User  <  NanoStore::Model      attribute  :name  

       attribute  :age      attribute  :created_at      bag  :cars   end     user  =  User.new(:name  =>  "Bob",  :age  =>  16,  :created_at  =>  Time.now)   user.save   users  =  User.find(:name  =>  {  NSFEqualTo  =>  "Ronald"  })        
  10. NPUJPODPDPBQPET •  $PDPBQPETͷϥΠϒϥϦΛ3VCZ.PUJPOͰ #  Rakefile   Motion::Project::App.setup  do  |app|  

       app.name  =  'HBFav2'      app.pods  do          pod  'SSPullToRefresh'  #  Cocoapods      end   end   #  in  ViewController   @ptrv  =  SSPullToRefreshView.alloc.initWithScrollView(...)  
  11. σόοά •  HEC͕࢖͑·͢ $  rake  debug=1  no_continue=1   [...]  

    (gdb)  break  hello_view.rb:10   Breakpoint  4  (hello_view.rb:10)  pending.   (gdb)  continue   Continuing.