Realmビギナーが知っとくべき内容で打線組んだwww

7d1521d950d9bc5697868830cb04ff2f?s=47 yimajo
March 12, 2015

 Realmビギナーが知っとくべき内容で打線組んだwww

potatotips15 で発表した資料です
http://connpass.com/event/12140/

7d1521d950d9bc5697868830cb04ff2f?s=128

yimajo

March 12, 2015
Tweet

Transcript

  1. 3FBMNϏΪφʔ͕஌ͬͱ͘΂͖ ಺༰Ͱଧઢ૊ΜͩXXX גࣜձࣾΩϡϦΦγςΟιϑτ΢ΣΞ ࠓ৓ળۣ !ZJNBKP ୈճQPUBUPUJQT

  2. ଧॱ कඋ બख໊  ༡ 3FBMNͷಡΈํ͸ʮϨϧϜʯ  ೋ 3-.0CKFDUαϒΫϥεͷϓϩύςΟఆ͕ٛΧϥϜΛࣔ͢ 

    த /4/VMMOJMͰอଘͰ͖ͳ͍  Ұ ओΩʔ͸TUSJOH͔੔਺Ͱͳ͚Ε͹͍͚ͳ͍  ӈ /4%BUF͕ϛϦඵΛอଘͰ͖ͯͳ͍  ࡾ 3FBMN +40/͕ࣗಈͰ*40ܗࣜͷจࣈྻΛ/4%BUFʹ ͯ͠͠·͏  ࠨ +40/&YQPSUͷίʔυ͸OJMΛߟྀ͍ͯ͠ͳ͍  ั 3-.0CKFDUͷϓϩύςΟଐੑ͸ॻ͔ͳ͍͜ͱΛਪ঑  ౤ /4*OUFHFS͡Όͳ͘JOU@UΛ࢖͏΂͖࣌΋͋Δ 3FBMN DPDPB WΛ࢖༻ɻόά͸मਖ਼͞ΕͨΓ࢓༷΋มΘΔͨΊ಺༰͸ӏವΈʹ͠ͳ͍Ͱ͍ͩ͘͞
  3. 3FBMN͸ಡΈํΛΧλΧφͰදݱ͢Δͱ ʮϨϧϜʯ

  4. ͦ΋ͦ΋3FBMNͱ͸ w 3FBMN͸ϞόΠϧϑΝʔετͰγϯϓϧ͔ͭϞμ ϯͳ࣍ੈ୅σʔλϕʔε w IUUQTHJUIVCDPNSFBMNSFBMNDPDPB w 0CKFDUJWF$ 4XJGUͱ"OESPJE͔Β΋࢖͑ΔϥΠ ϒϥϦ͕͋Δ

    w ϦΞϧϜ͡Όͳͯ͘ϨϧϜͱಡΉ
  5. ࠓճ͸શͯJ04ʹ͍ͭ ͯͷ࿩

  6. 3-.0CKFDUαϒΫϥεͷϓϩύςΟఆ͕ٛ ΧϥϜΛࣔ͢

  7. @interface Dog : RLMObject @property NSString *name; @end ϞσϧͰςʔϒϧఆٛ ࢖͑Δܕ͸

    #00- CPPM JOU /4*OUFHFS MPOH  qPBU EPVCMF $('MPBU  /44USJOH /4%BUF /4%BUB  3-.0CKFDUͷαϒΫϥε
  8. @interface Dog : RLMObject @property NSString *name; @property NSNumber *age;

    // ௥Ճͨ͠ @end ϞσϧͰςʔϒϧఆٛ ࢖͑ͳ͍ܕͰఆٛͯ͠͠·͏ͱz࣮ߦ࣌ʹྫ֎zɻ ͜Ε͸୯७ϛεͳͷͰͦͷΫϥεΛར༻͢Δࡍʹ໰ ୊͕෼͔Δͷ͸خ͍͠ɻ
  9. /4/VMMOJMͰอଘ͕Ͱ͖ͳ͍ͷͰσʔλ͕ ͳ͍͜ͱΛදͮ͠Β͍

  10. 8FC"1*Λར༻ͨ͠৔߹ ϨεϙϯεʹΦϓγϣφϧͳ߲໨͕͋Δ ͱ/4/VMMOJM͕ར༻Ͱ͖ͳ͍ͷ͸ਏ͍

  11. ٯʹ ϩʔΧϧͰ࡞੒ͨ͠σʔλΛ3FBMNʹอଘ͢Δ ৔߹͸Φϓγϣφϧͳ߲໨͸ ΋ͬͱগͳ͍͔΋͠Εͳ͍ͨΊ ͋·ΓؾʹͳΒͳ͍ͱ͸ࢥ͏

  12. ଥڠҊ w ͦͷ஋͕͋Δ͔ͳ͍͔ͷ#00-ϑϥάΛอଘ߲ ໨ͷҰͭͱͯ࣋ͭ͠ ଥڠҊ w ੔਺ͳΒ*/5@.*/ͳͲఆ਺Խ͞Ε͍ͯΔ࢖Θ Εͳͦ͞͏ͳ஋Ͱଘࡏ͠ͳ͍ͱ͍͏ҙຯ͚ͩΛ ࣔ͢

  13. ͪͳΈʹ

  14. /44USJOHʹ͸OJMΛ ಥͬࠐΊΔ

  15. None
  16. w OJM͕อଘͰ͖ͯΔΑ͏ʹݟ͑Δ͚Ͳ w ۭจࣈ!lz͕อଘ͞Ε͍ͯͯɺOJMͰ͸ͳ͍͔Β஫ ҙ͕ඞཁ

  17. ओΩʔ͸TUSJOH͔੔਺Ͱͳ͚Ε͹͍͚ͳ͍

  18. w ྫ֎ʹ͸TUSJOH͔JOUΛ࢖͑ͱॻ͍ͯ͋Δ w JOU͚ͩͰͳ͘MPOHͳͲ΋࢖͑ΔͷͰ੔਺Ͱ͋Ε ͹ྑ͍

  19. /4%BUF͕ϛϦඵΛอଘͰ͖ͯͳ͍

  20. w ݱࡏͷ࠷৽ W Ͱ΋࣌ؒͷখ਺఺ҎԼ͕੾ ΓࣺͯΒΕɺϛϦඵҎԼ͕อଘͰ͖ͳ͍ w IUUQTHJUIVCDPNSFBMNSFBMNDPDPB JTTVFT

  21. w /45JNF*OUFSWBM࢖͏ͷ͕ૉ௚ w ͕ͩ͋͘·Ͱج४஋͔Βͷ*OUFSWBMʹͳΔͷͰ ͦͷج४஋ΛͲ͜ʹ͢Δ͔͸ద੾ʹܾΊͨ͘ͳ Δ w 8FC"1*͔Β*40ܗࣜʢྫ 5 ʣͰૹΒΕͯ͘ΔΑ͏ͳ

    έʔεͳΒͦΕΛ/44USJOHͰอଘ͢Δͷ͸ѱ͍ํ ๏͡Όͳ͍ؾ͕͢Δ ϛϦඵҎԼ࢖͍͍ͨ࣌ͷ ଥڠҊ
  22. ଥڠҊͲͪΒΛબΜͰ΋ ಺෦อଘ͕Ͳ͏͋Εϝιουܦ༝ Ͱ/4%BUFΛฦ͢Α͏ʹ͢Ε͹ 3-.0CKFDUΛࢀর͢Δଆ͸ؾʹ͠ ͳ͍ͰࡁΉ͔΋

  23. @interface Dog : RLMObject @property NSTimeInterval *birthDateInterval; // NSDate͕ཉ͚͠Ε͹propertyΛNSDateʹͯ͠ฦ͢ɻ //

    birthDateInterval͕-1ͳΒnilΛฦͤ͹͍͍ - (NSDate *)birthDate; @end
  24. 3FBMN +40/͕ࣗಈͰ*40ܗࣜͷจ ࣈྻΛ/4%BUFʹͯ͠͠·͏

  25. 3FBMN +40/ͱ͍͏ ϥΠϒϥϦ͕͋Δ w +40/ͷϚοϐϯάϧʔϧΛ.BOUMFͷΑ͏ʹॻ ͚Δ w Ϛοϐϯάϧʔϧ͸3-.0CKFDUΛܧঝͨ͠Ϋϥ εͷΫϥεϝιουͱͯ͠هड़͠/4%JDUJPOBSZ Ͱฦ͢

    IUUQTHJUIVCDPNNBUUIFXDIFPL3FBMN+40/
  26. + (NSDictionary *)JSONInboundMappingDictionary { return @{ @"id": @"identifier", @"created_at": @"createdAt"

    }; } Ϛοϐϯάϧʔϧྫ LFZ͕KTPOͷLFZ WBMVF͕Ϛοϐϯά͢ΔϓϩύςΟ໊
  27. w *40ܗࣜͷจࣈྻ͸/4%BUFʹͯ͘͠ΕΔ w Ͱ΋/4%BUF͸ϛϦඵࣺͯΔ͠ w σʔλ͕ͳ͍ͱ͖/4%BUFͰOJMอ࣋͢Δͷϫʔ ΫΞϥ΢ϯυ͕ඞཁͳͷͰ w ೔࣌Λ/4%BUFͰอଘͨ͘͠ͳ͍࣌΋͋ͬͯ ͋Γ͕ͨ໎࿭తͳʜ

  28. +40/&YQPSUͷίʔυ ͸OJMΛҙ͍ࣝͯ͠ͳ͍

  29. +40/&YQPSUͱ͸ IUUQTHJUIVCDPN"INFE"MJ+40/&YQPSU

  30. +40/&YQPSUͱ͸ w +40/&YQPSU͸+40/ͷϑΝΠϧ͔ΒΫϥεΛఆ ٛͯ͘͠ΕΔπʔϧ w Ϛοϐϯά༻ͷϝιουͷίʔυ΋ੜ੒ͯ͠ग़ ྗͯ͘͠ΕΔ IUUQTHJUIVCDPN"INFE"MJ+40/&YQPSU

  31. ྫ - (instancetype)initWithDictionary:(NSDictionary *)dictionary { if(dictionary == nil || [dictionary

    isKindOfClass:[NSNull class]]){ return nil; } self = [super init]; if(![dictionary[@"id"] isKindOfClass:[NSNull class]]){ self.identifier = [dictionary[@"id"] integerValue]; } if(![dictionary[@"name"] isKindOfClass:[NSNull class]]){ self.name = dictionary[@"name"]; } return self; } ͨͩEJDUJPOBSZ<!lJEz>͕OJMͳΒ@JEFOUJpFS΋OJMʹͳΓྫ֎͕ ى͖ΔͷͰɺ͜ͷ৚݅ࣗମ΋ΧελϚΠζ͸ඞཁʹͳΔ
  32. +40/ &YQPSUͰࣗಈੜ੒͞ ΕΔίʔυΛݩʹΧελϚΠ ζ͍ͯ͘͠ͷ͕ྑͦ͞͏

  33. 3-.0CKFDUͷϓϩύςΟ ଐੑ͸ॻ͔ͳ͍͜ͱΛਪ঑

  34. w 3FBMNͰ͸ɺOPOBUPNJD BUPNJD TUSPOH DPQZ XFBLͷ Α͏ͳ0CKFDUJWF$ͷϓϩύςΟଐੑ͕ແࢹ͞Ε·͢ w 3FBMNͷதͰ͸ɺಠࣗͷ࠷దԽ͞Εͨଐੑ͕࢖ΘΕ·͢ɻ ͦͷͨΊɺࠞཚΛආ͚ΔͨΊʹɺ3FBMNϞσϧΫϥεΛએ

    ݴ͢Δͱ͖ɺϓϩύςΟଐੑΛ෇͚ͳ͍͜ͱΛਪ঑͍ͯ͠ ·͢ɻ w ϓϩύςΟଐੑΛ෇͚ͨ৔߹ɺ3-.0CKFDU͕3FBMNʹอ ଘ͞ΕΔ·Ͱ༗ޮʹͳΓ·͢ɻ ެࣜϦϑΝϨϯεΑΓ IUUQSFBMNJPKQEPDTDPDPB
  35. ແࢹ͞ΕΔͷ͔͞Εͳ ͍ͷ͔෼͔ΓͮΒ͍ʜ

  36. ͜͏͍͏͜ͱʁ %#ʹอଘ͞Εͨ 3-.0CKFDUΛ࡞ͬͨ ଐੑͷࢦఆ͕༗ޮ ଐੑͷࢦఆΛແࢹʁ w Կʹ͠Ζଐੑͷࢦఆ͸͠ͳ͍΄͏͕ྑͦ͞͏ %#͔Βऔಘ ଐੑͷࢦఆΛແࢹʁ

  37. /4*OUFHFSʹ͢ΔͱCJU$16ͰࠔΔ͜ͱ ΋͋Δ

  38. ωλ͕ਚ͖ͯ3FBMNͱ ௚઀ؔ܎ͳ͍ΜͰ͕͢

  39. w CJU$16ͷ৔߹/4*OUFHFS͸CJU w CJU޲͚ʹϏϧυ͞Ε্ͨͰCJU$16ͳΒ /4*OUFHFS͸CJUʹͳΔ w ϋʔυ΢ΣΞΞʔΩςΫνϟʹΑΒͣɺॴఆͷό Πτ௕Ͱ͋Δ͜ͱ͕อূ͞Εͨ૊ΈࠐΈσʔλ ܕ͕0CK$Ͱ΋࢖͑ΔͷͰͦΕΛ࢖͏΄͏͕ྑ͍ 8FC"1*ͰCJUͷ੔਺Λฦ

    ͞ΕΔࡍ
  40. @interface Employ : RLMObject @property uint64_t identifier; @end ྫ͑͹ූ߸ͳ͠CJUͷ੔਺Λอଘ͢Δඞཁ͕͋Δ ͳΒ/4*OUFHFSͰ͸ͳ͘JOU@U΍VJOU@UΛ࢖͑

    ͹͍͍ͱࢥ͏
  41. ͦͷଞ

  42. w 3FBMN DPDPB ͷόʔδϣϯΞοϓ͕଎͍ w /4/VMMOJMΛಥͬࠐΊͳ͍໰୊΋͙͢ʹղܾ͢Δ ͩΖ͏ͱࢥ͏ w %#ͱͯ͠Ϣʔβʔͷखݩʹ࢒ͬͯ͠·͏͜ͱͳ ͷͰมͳϫʔΫΞϥ΢ϯυΛͤͣͳΔ΂͘ૉ௚

    ͳରԠ͍ͨ͠