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

サーバーサイドエンジニアのためのiOSアプリ開発入門

typester
August 22, 2015

 サーバーサイドエンジニアのためのiOSアプリ開発入門

YAPC::Asia 2015

typester

August 22, 2015
Tweet

More Decks by typester

Other Decks in Technology

Transcript

  1. αʔόʔαΠυΤϯδχΞ
    ͷͨΊͷJ04ΞϓϦ։ൃೖ໳
    !UZQFTUFS

    :"1$"TJB

    View full-size slide

  2. J04ΞϓϦ։ൃ
    w 4XJGU
    w (PPECZF0CKFDUJWF$
    w ແྉͰ࣮ػసૹՄೳʹ 9DPEFҎ߱

    IUUQTEFWFMPQFSBQQMFDPNYDPEF
    EPXOMPBET

    View full-size slide

  3. ࢝ΊΔʹ͸ྑ͍࣌ظʂ

    View full-size slide

  4. $MBTT
    package Foo;

    use Moose;


    1;

    View full-size slide

  5. $MBTT
    class Foo {

    }

    View full-size slide

  6. *OIFSJUBODF
    package Dog;

    use Moose;


    extends ‘Animal’;


    1;

    View full-size slide

  7. *OIFSJUBODF
    class Dog: Animal {

    }

    View full-size slide

  8. JOTUBODFWBSJBCMF
    package Dog;

    use Moose;


    extends ‘Animal’;


    has ‘name’ => (

    is => ‘rw’,

    isa => ‘Str’,

    );


    1;

    View full-size slide

  9. JOTUBODFWBSJBCMF
    class Dog: Animal {

    var name: String = “”

    }

    View full-size slide

  10. MB[Z
    package Dog;

    use Moose;


    extends ‘Animal’;


    has ‘name’ => (

    is => ‘rw’,

    isa => ‘Str’,

    lazy => 1,

    default => sub {

    “John”;

    },

    );


    1;

    View full-size slide

  11. MB[Z
    class Dog: Animal {

    @lazy var name: String = {

    return “John”

    }()

    }

    View full-size slide

  12. JOJUJBMJ[FS
    package Dog;

    use Moose;


    extends ‘Animal’;


    sub BUILD {

    my ($self) = @_;

    # . . .

    }


    1;

    View full-size slide

  13. JOJUJBMJ[FS
    class Dog: Animal {

    init() {

    // . . .

    }

    }

    View full-size slide

  14. JOTUBODFGVODUJPO
    package Dog;

    use Moose;


    extends ‘Animal’;


    sub print_info {

    my ($self) = @_;

    printf ‘name=%s\n’, $self->name;

    }


    1;

    View full-size slide

  15. JOTUBODFGVODUJPO
    my $dog = Dog->new;

    $dog->print_info;

    View full-size slide

  16. JOTUBODFGVODUJPO
    class Dog: Animal {

    var name: String = “”


    func print_info() {

    println(“name=\(self.name)”)

    }

    }

    View full-size slide

  17. JOTUBODFGVODUJPO
    var dog = Dog()

    dog.print_info()

    View full-size slide

  18. େମΠϝʔδ͸఻Θͬ
    ͨͰ͠ΐ͏͔

    View full-size slide

  19. ࣮ࡍʹ͸4XJGUͷ΄͏͕ΊͪΌ
    ͪ͘Όػೳ๛෋ͳͷͰɺ͜ͷ
    ΍Γํʹ͸ແཧ͕͋Γ·͢ স

    View full-size slide

  20. 1FSM࢖͍͕4XJGUʹདྷͯ

    ҧ࿨ײͷͳ͍࠷େͷϙΠϯτ

    View full-size slide

  21. ϦϑΝϨϯεΧ΢ϯτ
    ํࣜ

    View full-size slide

  22. 1FSMͰΑ͘΍Δϛε
    my $t = AnyEvent->timer(

    after => 10,

    cb => sub {

    $self->do_something;

    },

    );

    View full-size slide

  23. 1FSMͰΑ͘΍Δϛε
    my $t = AnyEvent->timer(

    after => 10,

    cb => sub {

    $self->do_something;

    },

    );

    View full-size slide

  24. 1FSMͰΑ͘΍Δϛε
    my $t = AnyEvent->timer(

    after => 10,

    cb => sub {

    $self->do_something;

    },

    );

    Scalar::Util::weaken($self);

    View full-size slide

  25. *OTXJGU
    var t = Timer(10, cb: {

    () -> Void in

    self?.do_something()

    })

    View full-size slide

  26. *OTXJGU
    var t = Timer(10, cb: {

    [weak self] () -> Void in

    self?.do_something()

    })

    View full-size slide

  27. ;FSPJOHXFBL
    w 4XJGU0CKFDUJWF$ͷXFBLࢀর͸

    ;FSPJOHXFBLͱݺ͹ΕΔ
    w 1FSMͷXFBLࢀর͸ϦϑΝϨϯεΧ΢ϯτ͕͞
    Εͳ͍͚ͩ
    w 4XJGUͷ৔߹͸͞ΒʹɺࢀরΧ΢ϯτ͕ʹͳΔ
    ͱɺXFBLࢀর͍ͯ͠Δม਺͕ࣗಈతʹOJM
    [FSP
    ʹͳΔ

    View full-size slide

  28. 1FSMʹͳ͍͚Ͳॏཁͳ΍ͭΒ
    w 0QUJPOBMͱ͍͏֓೦
    w 1SPUPDPM

    View full-size slide

  29. 0QUJPOBMͱ͍͏֓೦
    w 4XJGUͰ͸

    WBSGPP4USJOH

    ͱఆٛͨ͠ม਺ʹ͸4USJOHҎ֎ೖΕΒΕͳ͍

    View full-size slide

  30. 0QUJPOBMͱ͍͏֓೦
    w WBSGPP4USJOH 

    ͱఆٛ͢ΔͱPQUJPOBMʹͳΔ
    w OJMPS4USJOH͕୅ೖՄೳ

    View full-size slide

  31. 0QUJPOBMͱ͍͏֓೦
    w ΞΫηε͢Δ࣌͸
    w TFMGGPP

    OJMͩͬͨ࣌͸DSBTI

    w JGMFUGPPTFMGGPP\

    ^

    ͕͓ͬͪ͜͢͢Ί

    View full-size slide

  32. 0QUJPOBMͱ͍͏֓೦
    w JGMFUCB[TFMGGPP CBS CB[\

    ^
    w 0QUJPOBMΛશ෦ͨͲͬͯ࠷ޙ·ͰOJM͡Όͳ͔ͬ
    ͚ͨ࣌ͩ

    View full-size slide

  33. 0QUJPOBMͱ͍͏֓೦
    w TFMGGPP EP@TPNFUIJOH

    w GPP͕OJMͩͬͨΒԿ΋͓͖ͳ͍

    View full-size slide

  34. 1SPUPDPM
    w (Pͷ*OUFSGBDFΈ͍ͨͳ΋ͷ
    w 4USVDU1SPUPDPMͰɺ΄Μͱʹ(PΈ͍ͨͳॻ
    ͖ํ΋Մೳ

    View full-size slide

  35. w DQBOpMF1PEpMF
    w DBSUPOJOTUBMM'PP

    QPEJOTUBMM'PP

    View full-size slide

  36. ͳΜ͔࡞ΔσϞ

    View full-size slide

  37. ϙΠϯτ
    w ࠷ॳ͔Β׬ᘳͳ΋ͷΛ࡞Ζ͏ͱ͠ͳ͍
    w ζϧͰ͖Δͱ͜Ζ͸ζϧ͢Δ
    w ࣗ෼͔͔ͭ͑͠ͳͯ͘ྑ͍
    w ඞཁʹͳͬͨ΋ͷ͚͍֮ͩ͑ͯ͘ͷָ͕ͩ͠਎
    ʹͭ͘

    View full-size slide

  38. ϙΠϯτ
    w ຊ৬ αʔόαΠυ
    ͷೳྗΛۦ࢖
    w ΫϥΠΞϯταΠυ͸ΊͬͪΌखൈ͖Ͱ͖ΔΑ
    ͏ʹαʔόͰ͕Μ͹Δ

    View full-size slide

  39. ϙΠϯλ
    w ੲͱ͕ͪͬͯ৘ใ͕ͦΖ͍ͬͯΔͷͰ

    ͋Μ·Γۤ࿑͠ͳ͍͸ͣ
    w ެࣜνϡʔτϦΞϧ

    4UBSU%FWFMPQJOHJ04"QQT 4XJGU

    w Ұ෦೔ຊޠʹ΋ͳͬͯ·͢

    IUUQTEFWFMPQFSBQQMFDPNKQEPDVNFOUBUJPO
    w ϐϯϙΠϯτʹ΍Γ͍ͨ͜ͱɾ࢖͏ϑϨʔϜϫʔΫ໊ͰάάΔ

    ˠ4UBDLPWFSqPX RJJUB

    View full-size slide