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

BubbleWrap

 BubbleWrap

Slides for my talk at #inspect 2013 - the first RubyMotion conference in Bruselles.

Marin Usalj

March 29, 2013
Tweet

More Decks by Marin Usalj

Other Decks in Programming

Transcript

  1. BubbleWrap
    Marin Usalj
    @mneorr
    Tuesday, April 2, 13

    View Slide

  2. iOS consultant
    Ruby <3
    Tuesday, April 2, 13

    View Slide

  3. ObjectiveRecord
    ObjectiveSugar
    Kiwi
    Bubblewrap
    Tuesday, April 2, 13

    View Slide

  4. [@3 times:^{
    NSLog(@"Hello!");
    }];
    // Hello!
    // Hello!
    // Hello!
    NSDate *future = @(24).days.fromNow;
    // 2012-12-25 20:49:05 +0000
    NSDate *past = @(1).month.ago;
    // 2012-11-01 20:50:28 +00:00
    NSString *sentence = NSStringWithFormat(@"This is a text-with-
    argument %@", @1234);
    [sentence split:@"-"]
    // array = this is a text, with, argument 1234
    ObjectiveSugar
    github.com/mneorr/ObjectiveSugar
    Tuesday, April 2, 13

    View Slide

  5. [cars each:^(id object) {
    NSLog(@"Car: %@", object);
    }];
    // Car: Testarossa
    // Car: F50
    // Car: F458 Italia
    [cars map:^id(id car){
    return @([[car substringToIndex:1] isEqualToString:@"F"]);
    }];
    // NO (Testarossa)
    // YES (F50)
    // YES (F458 Italia)
    ObjectiveSugar
    github.com/mneorr/ObjectiveSugar
    Tuesday, April 2, 13

    View Slide

  6. // creating
    [Person create:@{ @"name" : @"John", @"age" : @12 }];
    Person *john = [Person create];
    john.name = @"John";
    // save/delete
    [john save];
    [john delete];
    // querying
    Person *johnDoe = [Person where:@"name == 'John' AND surname =
    'Doe'"].first;
    NSArray *people = [Person where:@{ @"age" : @18 }];
    ObjectiveRecord
    github.com/mneorr/ObjectiveRecord
    Tuesday, April 2, 13

    View Slide

  7. “ActiveSupport for RubyMotion”
    Tuesday, April 2, 13

    View Slide

  8. Tuesday, April 2, 13

    View Slide

  9. Motivation
    Tuesday, April 2, 13

    View Slide

  10. AFJSONRequestOperation.JSONOperationWithReuqest(
    NSURLRequest.requestWithURL(
    NSURL.URLWithString(‘http://mneorr.com’)),
    success: ?
    failure: ?
    ).start
    Tuesday, April 2, 13

    View Slide

  11. AFJSONRequestOperation.JSONOperationWithReuqest(
    NSURLRequest.requestWithURL(
    NSURL.URLWithString(‘http://mneorr.com’)),
    success:^{
    # handle good response
    }
    failure:^{
    # handle bad response
    }).start
    Tuesday, April 2, 13

    View Slide

  12. Tuesday, April 2, 13

    View Slide

  13. AFJSONRequestOperation.JSONOperationWithReuqest(
    NSURLRequest.requestWithURL(
    NSURL.URLWithString(‘http://mneorr.com’)),
    success: lambda{|response|
    # handle good response
    }
    failure: lambda{|response, error|
    # handle bad response
    }).start
    Tuesday, April 2, 13

    View Slide

  14. Tuesday, April 2, 13

    View Slide

  15. AFJSONRequestOperation.JSONOperationWithReuqest(
    NSURLRequest.requestWithURL(
    NSURL.URLWithString(‘http://mneorr.com’)),
    success: lambda{ |request, response, json|
    # handle good response
    }
    failure: lambda{ |request, response, error, json|
    # handle bad response
    }).start
    Tuesday, April 2, 13

    View Slide

  16. BW::HTTP
    Tuesday, April 2, 13

    View Slide

  17. HTTP.get(‘http://mneorr.com’) do |response|
    if response.ok?
    # handle good response
    else
    # handle failure
    end
    end
    Tuesday, April 2, 13

    View Slide

  18. params = { foo: ‘bar’, baz: [:bang, :zsh] }
    HTTP.post(‘http://mneorr.com’, payload: params) do |response|
    if response.ok?
    # handle good response
    else
    # handle failure
    end
    end
    Tuesday, April 2, 13

    View Slide

  19. BW::Core
    Tuesday, April 2, 13

    View Slide

  20. > Device.iphone?
    # true
    > Device.ipad?
    # false
    > Device.front_camera?
    # true
    > Device.orientation
    # :portrait
    > Device.simulator?
    # true
    > Device.ios_version
    # "6.0"
    Tuesday, April 2, 13

    View Slide

  21. JSON.parse("{\"foo\":1,\"bar\":
    [1,2,3],\"baz\":\"awesome\"}")
    => { foo: 1, bar: [1,2,3], baz: “awesome” }
    JSON.generate({ foo: 1, bar: [1,2,3],
    baz: “awesome” })
    => "{\"foo\":1,\"bar\":[1,2,3],\"baz\":
    \"awesome\"}"
    Tuesday, April 2, 13

    View Slide

  22. BW.create_uuid
    => "68ED21DB-82E5-4A56-ABEB-73650C0DB701"
    '#FF8A19'.to_color
    => #
    App.open_url("http://mneorr.com")
    # Opens the url using the device's browser.
    (accepts a string url or an instance of
    Tuesday, April 2, 13

    View Slide

  23. Persistence
    Tuesday, April 2, 13

    View Slide

  24. [Client]: hey, how hard is
    it to store some user
    data?
    We may need to keep
    track of Foo and Bar!
    Tuesday, April 2, 13

    View Slide

  25. Tuesday, April 2, 13

    View Slide

  26. NSUserDefaults.standardUserDefaults
    .setValue(“Inspect”,
    forKey:”conference”)
    conf = NSUserDefaults.standardUserDefaults
    .valueForKey(“conference”)
    Tuesday, April 2, 13

    View Slide

  27. Y U NO SAVE?
    Tuesday, April 2, 13

    View Slide

  28. You didn’t
    #synchronize.
    Tuesday, April 2, 13

    View Slide

  29. NSUserDefaults.standardUserDefaults
    .setValue(“Inspect”,
    forKey:”conference”)
    NSUserDefaults.standardUserDefaults
    .synchronize
    Tuesday, April 2, 13

    View Slide

  30. include App
    Persistence[‘conference’] = “Inspect”
    conf = Persistence[‘conference’]
    Tuesday, April 2, 13

    View Slide

  31. BW::Location
    Tuesday, April 2, 13

    View Slide

  32. BW::Location.get do |result|
    result[:to].longitude
    result[:from].longitude
    end
    BW::Location.get_significant
    BW::Location.get_once
    Tuesday, April 2, 13

    View Slide

  33. BW::UI
    Tuesday, April 2, 13

    View Slide

  34. Tuesday, April 2, 13

    View Slide

  35. view.when_swiped
    view.when_pressed
    view.when_panned
    view.when_pinched
    view.when_rotated
    view.when_tapped
    Tuesday, April 2, 13

    View Slide

  36. @recognizer = view.when_swiped
    Tuesday, April 2, 13

    View Slide

  37. BW::Media
    Tuesday, April 2, 13

    View Slide

  38. @playa = BW::Media::Player.new
    @playa.play_modal(@local_file)
    Tuesday, April 2, 13

    View Slide

  39. BW::Reactor
    (EventMachine)
    Tuesday, April 2, 13

    View Slide

  40. “There is a ton of great stuff in
    BubbleWrap.”
    “If you’re doing any RubyMotion work, I
    think you should definitely checkout
    BubbleWrap!”
    - the changelog
    Tuesday, April 2, 13

    View Slide

  41. “To make our networking code
    painless, we’ll use BubbleWrap”
    - smashingmagazine.com
    “Lots of good stuff in BubbleWrap”
    - Darrin Holst
    Tuesday, April 2, 13

    View Slide

  42. “If there’s any one thing you can
    do after starting a RubyMotion
    project, it’s immediately drop
    BubbleWrap into your repo.”
    - Nick, 37 Signals
    Tuesday, April 2, 13

    View Slide

  43. github.com/rubymotion/bubblewrap
    bubblewrap.io
    Tuesday, April 2, 13

    View Slide

  44. Questions
    Tuesday, April 2, 13

    View Slide

  45. Thanks HipByte!
    Tuesday, April 2, 13

    View Slide