ããã«ã¡ã¯ãHabrïŒ ç§ã®ååã¯Yuri Buyanovã§ããç§ã¯TamTamã¡ãã»ã³ãžã£ãŒã®éçºè ã§ãã ä»æ¥ã¯ããããã©ã®ããã«äœæãããã©ã®ããã«å éšããæ§ç¯ããããã«ã€ããŠå°ãã話ãããããšæããŸãã TamTamã¯ãOKã¡ãã»ãŒãžã¢ããªã±ãŒã·ã§ã³ã«åºã¥ããŠéçºãããMail.Ru Groupã®æ°ããã¡ãã»ã³ãžã£ãŒã§ãã 2016幎ã«ã¯ããœãŒã·ã£ã«ãããã¯ãŒã¯ã§é »ç¹ã«ããåããã人ããå¥ã®ã¢ããªã±ãŒã·ã§ã³ã䜿çšããŠãããè¡ãããšã奜ã人ã®ããã«ãOdnoklassnikiã§å¥ã®ã¡ãã»ã³ãžã£ãŒãäœæããŸããã
å®éšã¯æåããããšãå€æãããããä»å¹Žã®åãã«ãç§ãã¡ã¯ç¬èªã®TamTamãã©ã³ãã®äžã§ãœãŒã·ã£ã«ãããã¯ãŒã¯ãšã¯å¥ã®ã¡ãã»ã³ãžã£ãŒãšããŠOKã¡ãã»ãŒãžãéçºããããšã«ããŸããããéå§ãªãŒãã£ãšã³ã¹ãåéããŸããã ããŒã³ãåŸã®æåã®æ°é±éã§ãæ°äžã®ãã£ã³ãã«ãTamTamã«ç»å ŽãããªãŒãã£ãšã³ã¹ã¯OKã¡ãã»ãŒãžã®ããã«ç©æ¥µçã«ã³ãã¥ãã±ãŒã·ã§ã³ãç¶ããŸããã ããã¯ãã¢ããªã±ãŒã·ã§ã³ã®è¿ éãªäœæ¥ãšããã€ãã®æè¡çæ©èœã®ãããã§å¯èœã«ãªããŸããã ãããã«ã€ããŠè©³ãã説æããŸãã
ã¢ã€ãã¢ãæãã€ããå°é£
å°é£ããå§ããŸãããã補åã«åŸã§å®è£ ãããæçµçã«ã¢ããªã±ãŒã·ã§ã³ã®å©ç¹ã«ãªã£ãã¢ã€ãã¢ãç§ãã¡ã«ãããããã®ã¯åœŒãã§ããã ããã¯äž»ã«ã¡ãã»ã³ãžã£ãŒã®é«éã§å®å®ããä»äºã«ã€ããŠã§ãã
TamTamã®æåã®èŠèŽè ã¯ãã¢ãã€ã«ãããã¯ãŒã¯ã®äžèŠåãªã«ãã¬ããžïŒããã³åºå®ã€ã³ã¿ãŒãããã®å®å šãªæ¬ åŠãå«ãïŒãå«ãäžçäžããã§ãã 倧éœåžä»¥å€ã®äžéšã®CISè«žåœã§ã¯ãäžè¬ã«2Gæ¥ç¶ãå¯äžã®ã€ã³ã¿ãŒããããŠã£ã³ããŠã§ãã
ãŸãããã¹ãŠã®æœåšçãªTamTamãŠãŒã¶ãŒããæ¯å¹Žãµã ã¹ã³ããæ°ããiPhoneãŸãã¯HOT NOVELãè³Œå ¥ããããã§ã¯ãªãããšãéèŠã§ããã çµ±èšã«ãããšããŠãŒã¶ãŒã®éã§æã人æ°ã®ããiOSçšããã€ã¹ã¯iPhone 5sã§ãããAndroidçšã®å®äŸ¡ãªGalaxy 2014-2015ãªãªãŒã¹ã§ãã åæã«ãTamTamã®èŠèŽè ã¯ããªãè¥ãã§ããæ¯æ¥ã®èŠèŽè ã®28ïŒ ã¯27ã34æ³ã§ããããŠãŒã¶ãŒã®ååïŒ54ïŒ ïŒã¯35æ³æªæºã§ãã
ãããã£ãŠãæåããã¡ãã»ã³ãžã£ãŒã®éçºã«ãããåªå åéã®1ã€ã¯ã é床ãšãããã¯ãŒã¯ã®æäœã®äž¡æ¹ã®èŠ³ç¹ããã¢ããªã±ãŒã·ã§ã³ãæé©åããããšã§ããã ã€ãŸãããŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ãä»»æã®æ¥ç¶ã¬ãã«ã§åäœãããããšã¯æç¥ã§ããŸããã§ããã èŠèŽè ã®å¢å ã䌎ããŸãã TamTamã®æåã®æ°ãæã¯è¯ãæ°åã瀺ããŠããŸããã€ã³ã¹ããŒã«æ°ã¯ãã§ã«300äžã«è¿ã¥ããŠããããã£ãã«æ°ã¯ãã§ã«50,000ãè¶ ããŠããŸãã
ã¢ããªã±ãŒã·ã§ã³ãé«éåããæ¹æ³
ãŠãŒã¶ãŒã®èŠ³ç¹ããèŠãããã©ãŒãã³ã¹ã¯ãäž»ã«èµ·åã®é床ã§ãã æ°ããã³ã³ãã³ãã衚瀺ãããåã«çµéããæéïŒããšãã°ãããã·ã¥éç¥ã«ãã£ãŠæ°ããã¡ãã»ãŒãžã§ãã£ãããéããšãïŒã äœåå šäœã®æ»ããã-ç¹ã«ã¹ã¯ããŒã«ã iOSããŒã ã§ã¯ãiPhone 5ããã³iPhone 4Sã®ããã©ãŒãã³ã¹ããã¹ãããã³æž¬å®ããããšããŠããŸãã AndroidããŒã ã¯ã1000ã«ãŒãã«ã®Galaxy S3ããã³Megafonãã°ã€ã³ãèªç±ã«äœ¿çšã§ããŸãã ãã®çµæãã¢ããªã±ãŒã·ã§ã³ã¯ãã匷åãªããã€ã¹ã§é£ã¶ã ãã§ãã
åãã¹ãã¢ã»ã³ããªã§ã1ç§ãããã®ãã¬ãŒã ã«ãŠã³ã¿ãŒãæå¹ã«ã§ããŸãããŸããããã«ããã¯ã§ã®æäœã®æéã¯ãã°ãšçµ±èšã·ã¹ãã ã«èšé²ãããŸãã
ããšãã°ããã®ã°ã©ãã¯ãããã·ã¥ã§éããšãã®ã¢ããªã±ãŒã·ã§ã³ã®èµ·åããããŠãŒã¶ãŒããã®ç¹å®ã®ã¡ãã»ãŒãžãç»é¢ã«è¡šç€ºãããŸã§ã®æéã瀺ããŠããŸãã ã°ã©ãäžã®2ã€ã®ããããã¯ãååããã³ãã¹ãŠã®ãŠãŒã¶ãŒãããã·ã¥ããã³ã³ãã³ããå«ããããšã«å¯Ÿå¿ããŠããŸãã
è±å¯ãªããŒã«ãšã¡ããªãã¯ã«ããããããã䞻芳çãªææ ã¯ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãè©äŸ¡ããããã®äž»èŠãªããŒã«ã®ãŸãŸã§ãã ã¡ãã»ãŒãžç»é¢ãéããšãã«èš±å®¹ãããããªç§åäœã®é 延ãæ£ç¢ºã«èšãããšã¯ã§ããŸããããã»ãšãã©ã®äººã¯ãã¢ããªã±ãŒã·ã§ã³ãããã«ãã ãšæããŠãããã©ãããç¥ãããšãã§ããŸãã
ã©ã®ããã«æé©åããã®ã§ããïŒ ãŸããã¡ã€ã³ã¹ããªãŒã ããå¯èœãªãã¹ãŠã®ãã®ãåé€ããŸãïŒããŒã¿ããŒã¹ã®æäœïŒä»¥äžã§è©³ãã説æããŸãïŒããããã¯ãŒã¯ã®æäœãããŒã¿ã®ã·ãªã¢ã«åãšéã·ãªã¢ã«åãç»åã®åŠçãããã³æ€åã«é¢é£ããèšç®ã§ãã
ã¢ããªã±ãŒã·ã§ã³ãèµ·åãããšãããŸãã¯ãã£ããç»é¢ãéããšããããã¯ã°ã©ãŠã³ãã§éãæäœãå®è¡ããŠããç®ã«èŠããé 延ããç§ãã¡ãæããŸããã ãããã£ãŠãçµçãªã©ã®äžéšã®æäœã¯æéå ã«æé©åããå¿ èŠããããŸãããä»ã®æäœã¯ã¡ãã»ãŒãžãåä¿¡ããŠââããã«å®è¡ããå®è¡çµæãããŒã¿ããŒã¹ã«ãã£ãã·ã¥ããã®ãæé©ã§ãã
ããã«ããã¯ã®ãããµãŒãããŒãã£ã®ãœãªã¥ãŒã·ã§ã³ãšã©ã€ãã©ãªãéžæãããšããã¹ããŒããšã³ã³ãã¯ãããèæ ®ã«å ¥ããããšããŸããã ç¹ã«ããããMessagePackãéžæããçç±ã§ããïŒiOSã§ã¯å ·äœçã«ç°ãªãå®è£ ã®ãã³ãããŒã¯ãäœæããŸããïŒãããŒã¿ããªããžã§ã¯ãã«ãããã³ã°ããã©ã€ãã©ãªãMantleããYYModelã«å€æŽãããã©ãã£ãã¯ãå§çž®ããã¢ã«ãŽãªãºã ãšããŠlz4ã§åæ¢ããŸãã ã
ããã«ã ã¹ã ãŒãºãªã€ã³ã¿ãŒãã§ã€ã¹ãå®çŸããããã«ãã¬ã³ããªã³ã°ãçåçã«æé©åããŸãã
- ããã»ããµãããŒããããªãã¹ã¯ãªãŒã³ã¬ã³ããªã³ã°ãé¿ããŸãã
- ã¡ã€ã³ã¹ããªãŒã ã§åäœããæšæºã®UIViewContentModeã䜿çšãã代ããã«ãããã¯ã°ã©ãŠã³ãã§äºåã«ç»åã®ãµã€ãºãå€æŽããŸãã
- UIéå±€ãããããã©ããããã€ã·ã³ãã«ã«ããŸãã
- äœæã³ã¹ããé«ããããªããžã§ã¯ããšããŒã¿ããã£ãã·ã¥ããŸãã ããã¹ããå«ãã»ã«ã®é«ãããå§ãŸããYYTextLayoutïŒ YYTextã©ã€ãã©ãªå ã®ããã¹ãã®è¡šç€ºã«é¢ããæ å ±ãæ ŒçŽãããªããžã§ã¯ãïŒãNSAttributedStringsãããã«ã¯UIViewèªäœã§çµããã
ãã¹ãŠã®ãªã¹ãã«ã¯ãèªåã¬ã€ã¢ãŠãã®ãªãæåã¬ã€ã¢ãŠãããããŸãã èªåã¬ã€ã¢ãŠãã倧奜ãã§ãã³ãŒãã§Masonryã䜿çšãã宣èšåã¬ã€ã¢ãŠãã䜿çšããŠããŸãããé©åãªå Žåã«ã®ã¿äœ¿çšããŸãã
ãªãã©ã€ã³ã§æªãã€ã³ã¿ãŒãããã§äœæ¥ãã
ãããã¯ãŒã¯ã䜿çšããå Žåãé«éã§ã³ã³ãã¯ããªãããã³ã«ãšã¢ã°ã¬ãã·ããªãã£ãã·ã¥ãéžæããããšã«ããããã©ãã£ãã¯ãšé 延ãæå°éã«æããããšããŸãã
ãµãŒããŒãšéä¿¡ããæ¹æ³ãšããŠãTCPãœã±ãããšãã€ããªãããã³ã«ã®ã¿ã䜿çšããŸãã ããã«ããããµãŒããŒããæŽæ°ããªã¢ã«ã¿ã€ã ã§åä¿¡ããããšãšããã䜿ãæ £ãããèŠæ±/å¿çãã¢ãŒãã§äœæ¥ããããšãã§ããŸãã
APIèªäœãã€ãŸãäœã¬ãã«ãããã³ã«ã®äžã«ããäžé£ã®ã³ãã³ãã¯ãå°æ¥ãå¥ã®ãã©ã³ã¹ããŒãã®äžãããšãã°Webãœã±ããã«å®è£ ã§ããŸãã ããããã¹ãŠã«ãããã¢ããªã±ãŒã·ã§ã³ã®äžäœã¬ãã«ã®ããžãã¯ã«è§Šããå¿ èŠã¯ãããŸããã
ããã±ãŒãžèªäœã¯ããµãŒãã¹ã³ãŒãïŒã³ãã³ãã³ãŒãããããã³ã«ããŒãžã§ã³ããã€ããŒãé·ïŒãå«ãåºå®é·ããããŒã§æ§æãããŠããŸãã èŠæ±ãžã®å¿çã¯ç°ãªãé åºã§éããããµãŒããŒã³ãã³ããšæ··åãããå¯èœæ§ããããããããããŒã«èŠæ±ãšå¿çããªã³ã¯ã§ããã·ãŒã±ã³ã¹çªå·ããããŸãã
ãã€ããŒãã®åœ¢åŒãšããŠãã¡ãã»ãŒãžããã¯ãè©Šãããšã«ããŸããã åè·¯ã®é£ããã¿ã¹ã¯ãå¿ èŠãšãããéåžžã«ã³ã³ãã¯ãã§ãå€ãã®ãã©ãããã©ãŒã çšã®éåžžã«æ°ã®å©ããã·ãªã¢ã«åã©ã€ãã©ãªãåããŠããŸãã å®éãããã¯JSONã®å¹æçãªãã€ããªã¢ããã°ã§ãã ãã©ãã£ãã¯ã®æ¶è²»ãããã«åæžããããã«ãlz4ã¢ã«ãŽãªãºã ã§ãã€ããŒããå§çž®ããŸãã ãŸãããã®é床ãšCPUããã³ããããªãŒã®è»œè² è·ã®ããã«éžæããŸããã
äžè¯ãããã¯ãŒã¯ã§ã®ã¢ããªã±ãŒã·ã§ã³ã®æ£åžžãªåäœãä¿èšŒããäž»ãªæ¹æ³ã®1ã€ã¯ã ãªãã©ã€ã³ãµããŒããæ倧åããããšã§ãã ã¢ããªã±ãŒã·ã§ã³ã¯æ倧ããŒã¿ããã£ãã·ã¥ããåæã«è²»ããæéãšãã©ãã£ãã¯ãæžãããæ¥ç¶ã衚瀺ããããŸã§ã³ãã³ãã®éä¿¡ãé ãããããšãã§ããå¿ èŠããããŸãã ããã«ã次ã«ã¢ããªã±ãŒã·ã§ã³ãèµ·åãããšãã«ãæ¥ç¶ãè¿ãããå ŽåããããŸããã€ãŸããéä¿¡äžã®ãã¹ãŠã®ä¿çäžã®ã¿ã¹ã¯ã¯ããŒã¿ããŒã¹ã«ä¿åã§ããã¯ãã§ãã
æ¥ç¶åŸãã¯ã©ã€ã¢ã³ãã¯èªèšŒãè¡ããšåæã«ãéèŠãªããŒã¿ïŒèšå®ãé£çµ¡å ã®ãªã¹ããææ°ã®ã¡ãã»ãŒãžãšã®ãã£ããïŒãèŠæ±ããŸãã æåŸã®æŽæ°ã®ã¿ã€ã ã¹ã¿ã³ããïŒãµãŒããŒã®æéæ ã«ïŒä¿åããããããªã¯ãšã¹ãã«æž¡ããå®éã«å€æŽããããã®ã®ã¿ãååŸããŸãã æ¥ç¶ã確ç«ããããšãæ°ããã¡ãã»ãŒãžãé£çµ¡å ããŒã¿ã®å€æŽãªã©ããªã¢ã«ã¿ã€ã ã®æŽæ°ãåä¿¡ã§ããŸãã
ãã£ããå±¥æŽã¯ããå°ãè€éã§ãã ãã¹ãŠã®ãã£ããã®å±¥æŽå šäœãäºåã«ã¢ããããŒãããã®ã¯ç¡æå³ã§ãããäžåºŠåŸãã®ã¯ãã£ãã·ã¥ããŠãããèããªãããã«ããããšã§ãã ãã£ããå±¥æŽã®ã©ã®ã»ã¯ã·ã§ã³ããã£ãã·ã¥ãããŠããããèŠããšãå±¥æŽã«ãã®ã£ããããããããšãããããŸãã ããšãã°ããã°ã€ã³åŸã«ãã£ãããªã¹ããæŽæ°ãããšããã£ããã®æåŸã®ã¡ãã»ãŒãžãå€æŽãããããšãããããŸããã åæã«ãåã®ã»ãã·ã§ã³ã§ãã£ãã·ã¥ããããã£ããå±¥æŽã®ã»ã¯ã·ã§ã³ïŒãŸãã¯ããã€ãã®ã»ã¯ã·ã§ã³ïŒãããŒã¿ããŒã¹ã«ãããŸãã ããã«ãæåŸã®ãã£ããã¡ãã»ãŒãžãšä»¥åã«ãã£ãã·ã¥ãããã¡ãã»ãŒãžã®éã«ãµãŒããŒäžã«ããã¡ãã»ãŒãžã®æ°ãããããªããããè€éããå¢ããŸãã
ãããã£ãŠãã¡ãã»ãŒãžèªäœã«å ããŠãé£ç¶ããå±¥æŽã«é¢ããã¡ã¿ããŒã¿ïŒãã£ãã·ã¥ãããã£ã³ã¯ïŒãä¿åããŸãã ãã£ãããã¹ã¯ããŒã«ãããšãããã®æ å ±ã䜿çšããŸããããŒã¿ããŒã¹ãã次ã®ããŒãžãããŒããããããµãŒããŒã«ãªã¯ãšã¹ããéä¿¡ãããã決å®ããã®ã«åœ¹ç«ã¡ãŸãã ãŸãã¯å€åäž¡æ¹ãè¡ããŸãã ãµãŒããŒããå±¥æŽã®æ°ããã»ã¯ã·ã§ã³ãåä¿¡ãããšããããã®ãã£ã³ã¯ã¯ãµã€ãºãå€æŽããŠäºãã«ããŒãžããŸãïŒåä¿¡ããå±¥æŽã®ã»ã¯ã·ã§ã³ãããŒã¿ããŒã¹ã§äœ¿çšå¯èœãª2ã€ã®ç°ãªããã£ã³ã¯ãæ¥ç¶ããŠããããšãã¯ã©ã€ã¢ã³ããç解ããŠããå ŽåïŒã
å€ãã®æäœããªãã©ã€ã³ã§å®è¡ã§ãããããã¿ã¹ã¯ãä¿åããã¡ã«ããºã ãéçºããŸããã 圌ã¯ãã¿ã¹ã¯ãå®è¡ããæ¹æ³ãã¿ã¹ã¯ã®å®äºãåŸ ã€æ¹æ³ãããŒã¿ããŒã¹ã«ã¹ããŒã¿ã¹ãä¿åããæ¹æ³ããŸãã¯ã¢ããªã±ãŒã·ã§ã³ã®èµ·åæã«ããŒãããŠå®è¡ããæ¹æ³ãç¥ã£ãŠããŸãã
ã¿ã¹ã¯ã¯ããŒã¿ããŒã¹ã«ä¿åã§ããå®è¡ããžãã¯å šäœãã«ãã»ã«åããŸãã ä»ã®ã¿ã¹ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãžã®äŸåé¢ä¿ã¯éåžžã«è€éã«ãªãå¯èœæ§ãããããããããã®è¿œè·¡ãã¿ã¹ã¯èªäœã«å®è£ ãããŸãã ããšãã°ãåçä»ãã®ã¡ãã»ãŒãžãéä¿¡ããã¿ã¹ã¯ã¯ãåçãåŠçãããCDNã«ã¢ããããŒããããŠããããšã確èªãïŒãã®ãããåå¥ã®ã¿ã¹ã¯ã責任ãè² ããŸãïŒããããã¯ãŒã¯æ¥ç¶ãåŸ æ©ãïŒå¿ èŠãªå ŽåïŒãã¡ãã»ãŒãžã®ã¿ãçŽæ¥éä¿¡ããããšããŸãã
ã¹ã ãŒãºãªã¢ããªã±ãŒã·ã§ã³æäœã®ããã®2ã€ã®ããªãã¯
䜿ããããã¹ã ãŒãºãªã€ã³ã¿ãŒãã§ã€ã¹ãäœæã§ããªãã·ã¹ãã ã®å¶éãåé¿ããããã«äœ¿çšããããã€ãã®ããªãã¯ã«ã€ããŠå°ãã話ããŸãã iOSã¢ããªã±ãŒã·ã§ã³ã®äŸã
éçºã®é£ããã®1ã€ã¯ããã£ããå ã§ã®ç¡éã¹ã¯ããŒã«ãã€ãŸãããã£ãããäžã«ã¹ã¯ããŒã«ãããšãã«ãŠãŒã¶ãŒã«è¡šç€ºãããªãã¡ãã»ãŒãžå±¥æŽãããŒãããããšã§ããã 99ïŒ ã®å ŽåããŠãŒã¶ãŒã¯ãã£ããã®æäžéšã«äœçœ®ããŠãããå€ãã¡ãã»ãŒãžãèªãããã«ã¹ã¯ããŒã«ã¢ããããããšèããŠããŸãã ããã§ã2ã€ã®åé¡ã«çŽé¢ããŠããŸãã
ãŸããã¡ãã»ãŒãžãªã¹ãã®äžçªäžã«åžžã«ã¶ã€ãããæ°ç»é¢ããšã«ããŠã³ããŒããåŸ ã€ã®ã¯é¢åã§ãã ãã®åé¡ã解決ããã®ã¯ããã»ã©é£ãããããŸããã§ããããŠãŒã¶ãŒãäžçªäžãŸã§ã¹ã¯ããŒã«ããŠããããããèŠãããŸã§åŸ ããªãã£ãã®ã§ãããã¹ã¯ããŒã«äžã§ãã£ãŠãäºåã«ã¹ããŒãªãŒã®åã®ããŒãžããªã¯ãšã¹ãããããšããŸããïŒããŒã«ã«ãã£ãã·ã¥ãšãµãŒããŒã®äž¡æ¹ããã ãã£ãã·ã¥ãŸãã¯ã¯ã€ãã¯æ¥ç¶ã«ã¡ãã»ãŒãžãããå ŽåããŠãŒã¶ãŒã¯æ°ããã¡ãã»ãŒãžããã¯ã衚瀺ã§ãããŸã§ã«æäžéšãŸã§ã¹ã¯ããŒã«ããæéããããŸããã
2çªç®ã®åé¡ã¯ããæ·±å»ã§ããããšãå€æããŸãããã¡ãã»ãŒãžãªã¹ãã®å é ã«ãã®ãããªããŒãžãæ¿å ¥ããåŸïŒUITableViewã«åºã¥ããŠäœæïŒãæ¢ã«ããŒããããã»ã¯ã·ã§ã³ã®contentOffsetãã·ããããã¹ã¯ããŒã«ãããžã£ã³ããããŸãã ãã¡ãããæ¿å ¥ãããããŒãžã®ãµã€ãºãèšç®ããŠcontentOffsetãå ã«æ»ãããšãã§ããŸãããããã¯ã¹ã¯ããŒã«ã¢ãã¡ãŒã·ã§ã³ã®æ¥æ¿ãªåæ¢ã«ã€ãªããããŠãŒã¶ãŒã«ãšã£ãŠtheããŠæããããªããã®ã«ãªããŸãã ããšãã°ãKVOãä»ããŠcontentSizeããŒãã«ã远跡ãããªã©ãããŸããŸãªæ¹æ³ã§ãããå®è¡ããããšããŸããããåžžã«å€±æããŸãããUITableViewã¯ããªã¹ãã®æäžéšã«é ç®ãè¿œå ã§ããªãã ãã§ãã
ãã®çµæãäžé£ã®è©Šè¡ã®åŸãäžçš®ã®ãããã¯ããé©çšããããšã§ãã®åé¡ã解決ããããšãã§ããŸããã.transformã䜿çšããŠãªã¹ããäžäžéã«ããåã»ã«ãå察æ¹åã«å転ããŸãã ãŠãŒã¶ãŒã¯äœãæ°ã¥ããŸããããcontentOffsetã¯äžããã«ãŠã³ããããããã«ãªããå€ãã¡ãã»ãŒãžãèªã¿èŸŒãã§ãäœã®åœ±é¿ããããŸããã
ãã®ãœãªã¥ãŒã·ã§ã³ã«ã¯ããã€ãã®èœãšãç©ŽããããŸãããããããåé¿ããããšãã§ããŸããã ãŸããéã»ã«ã€ã³ããã¯ã¹ãããŒã¿ã¢ãã«ã®ã€ã³ããã¯ã¹ã«å€æããå¿ èŠããããŸããéãåæ§ã§ãã ã»ã¯ã·ã§ã³ãè€æ°ããå Žåãèšç®ã¯éåžžã«è€éã«ãªãããã1ã€ã«å¶éããããšããå§ãããŸãã ãã¡ãããããã«ãããããŒãã£ã³ã°ã»ã¯ã·ã§ã³ããããŒã䜿çšããããšã¯ã§ããŸãããããã¯ããã£ããç»é¢ã§ãããšãã°å±¥æŽã®æ¥ä»ããšã«åºåãæåã衚瀺ããã®ã«åœ¹ç«ã¡ãŸãã ããããæçµçã«ãããŒãã£ã³ã°ã»ãã¬ãŒã¿ãŒãæåã§è¡ãã®ã¯ããã»ã©é£ãããªãããšãå€æããŸããã
第äºã«ããŸãã«ããžã§ã¹ãã£ãæäœãããšããªã©ãã»ã«å ã®åº§æšãèšç®ããã®ãé£ããå ŽåããããŸããããã¹ãŠã解決ããããšãã§ããŸãã 第äžã«ãããŒã¿ãããŒããããšãã«åé¡ãæ»ããŸãããã¹ã¯ããŒã«ããŠã³ãããšãã«ããŒãããããšã¯éåžžã«ãŸãã§ãããããç§ãã¡ã«ãšã£ãŠããã»ã©å€§ããªåé¡ã§ã¯ãããŸããã ãã®å Žåãã¹ã¯ããŒã«äžã«ããªããŒãã¯è¡ããŸãããããŠãŒã¶ãŒãããŒãã«ã®äžçªäžãŸã§ã¹ã¯ããŒã«ããŠããããŒãã€ã³ãžã±ãŒã¿ãŒã衚瀺ããããŒãã«ãæŽæ°ããŠcontentOffsetãå€æŽããã®ãåŸ ã¡ãŸãã
2ã€ç®ã®åé¡ã¯ãã¢ãã¡ãŒã·ã§ã³åãããéåæã®ãªã¹ãæŽæ°ã§ãã è€æ°ã®ç¬ç«ããæŽæ°ãã»ãŒåæã«çºçããå ŽåïŒããšãã°ãå±¥æŽããŒãžããã£ããã®äžéšã«ããŒããããæ°ããã¡ãã»ãŒãžãäžéšã«å°çããå ŽåïŒãtableViewããªã²ãŒãã«ãã£ãŠäœ¿çšãããããŒã¿ã¯ãåã®æŽæ°ã®ã¢ãã¡ãŒã·ã§ã³ãçµäºããŠããªããŠãå€æŽã§ããŸãã
ããã«ãããUITableViewãééã£ãã»ã«ãã¬ã³ããªã³ã°ããããå®å šã«ã¯ã©ãã·ã¥ãããããå¯èœæ§ããããŸããããã¯ã以åã®ããã¯ã䜿çšããå Žåã«çºçããå¯èœæ§ãããã«é«ããªããŸãã ãã¡ãããUITableViewã§åæããreloadDataã¡ãœãããåç §ããããšãã§ããŸãããããã¯ç¹æ» ãã¹ã¯ããŒã«ã®åæ¢ããã®ä»ã®ãŠãŒã¶ãŒã®è¿·æã«ã€ãªãããŸãã
ç¹ã«ãã®ãããªå Žåã«ã¯ããã®ãããªæŽæ°ã®é 次åŠçã®ããã«å¥ã®ãã¥ãŒãäœæããŸããã ãã¹ãŠã®ã¢ãã«å€æŽãšUIã§ã®ãããã³ã°ã¯ããã¥ãŒã«å ¥ãããããããã¯å ã§è¡ãããŸãã ãã®å Žåããããã¯ã¯ã¢ãã¡ãŒã·ã§ã³ãŸãã¯ãã®ä»ã®éåææäœã®éå§æã«ãã¥ãŒãããã¯ããçµäºæã«ããã¯ã解é€ã§ããŸãã ãããã£ãŠãããŒãã«ã«å¯Ÿãããã¹ãŠã®äœæ¥ã¯é çªã«è¡ãããããŒã¿ã¯åã®ã¢ãã¡ãŒã·ã§ã³ãå®äºãããŸã§å€æŽãããŸããã
æç¶æ§
iOSã¯ã©ã€ã¢ã³ãã§ããŒã¿ããã£ãã·ã¥ããã«ã¯ãYapDatabaseã©ã€ãã©ãªã䜿çšããŸã ã
YapDatabaseã¯ãéåžžã«å€ãã®æ©èœã»ãããåããSQLiteäžã®Key-Valueãªããžããªã§ãã ãã®ã©ã€ãã©ãªã¯ãCoreDataãããã¯ããã«ã·ã³ãã«ã§æè»æ§ããããŸãã ããã§ã¯ãããŒã¿ããŒã¹å ã®ãªããžã§ã¯ããã·ãªã¢ã«åããã¡ã«ããºã ãéžæã§ããŸããããã©ã«ãã§ã¯NSCodingã§ãããåãMessagePackã䜿çšããŸãã
YapDatabaseã¯ãåºæ¬ã¯ã©ã¹ããã®ãªããžã§ã¯ãã®ç¶æ¿ããããã³ã«ã®å®è£ ãå¿ èŠãšããããªããžã§ã¯ããã³ã³ããã¹ãã«ãã€ã³ãããŸããã èªã¿åãããã³æžã蟌ã¿ã¯ãåæãã©ã³ã¶ã¯ã·ã§ã³ãŸãã¯éåæãã©ã³ã¶ã¯ã·ã§ã³ã䜿çšããŠå®è¡ãããŸãã
ãŸããæ¡åŒµã·ã¹ãã ã®å©ããåããŠããå®éã®ãããŒã¿ããŒã¹ãšåããã¹ãŠã®æ©èœã䜿çšã§ããŸããä»»æã®SQLã¯ãšãªãšããã€ãã®ãã£ãŒã«ãã®ã€ã³ããã¯ã¹äœæããã«ããã¹ãæ€çŽ¢ãå€æŽãžã®ãµãã¹ã¯ãªãã·ã§ã³ïŒNSFetchedResultsControllerãªã©ïŒããã©ã°ã€ã³æå·åãCloudKitã§ã®äœæ¥ãªã©Hello-worldããã§ããŒã¿ããŒã¹ãæäœããäŸã¯ç€ºããŸããããããã¯githubã®wikiã«ãããŸã ã
ç§ã®å¥œã¿ã§ã¯ãYapDatabaseã¯ã³ãŒãã®çç£æ§ãšãããããããåäžãããŸãããç§ã®ååã®äœäººãã¯ãããããŸã奜ãã§ã¯ãããŸããã ãããŠãããããç解ããããšãã§ããŸããCoreDataãé·æé䜿çšããåŸãYapDatabaseã«åãæ¿ããã«ã¯ãè³ãå°ãå転ãããå¿ èŠããããŸãã
ããã«ãè€æ°ã®æ¥ç¶ãä»ããŠããŒã¿ããŒã¹ãéåæã§æäœããå ŽåãããŒã¿ããŒã¹ã1ã€ãŸãã¯ç°ãªãæ¥ç¶ãä»ããŠäžŠåèªã¿åãããã³æžã蟌ã¿èŠæ±ãåŠçããæ¹æ³ãç解ããå¿ èŠããããŸãã ãŸãããªããžã§ã¯ãã¯ããŒã¿ããŒã¹å šäœã§æŽæ°ãããããšãå¿ããªãã§ãã ããã å°ãåã«èªãã§å€æŽããã€ã³ã¹ã¿ã³ã¹ãä¿åããããšã¯ã§ããŸããã ããŒã¿ããŒã¹ãããªããžã§ã¯ããèªã¿åããå¿ èŠã«å¿ããŠå€æŽããåäžã®ãã©ã³ã¶ã¯ã·ã§ã³ã§æžãæ»ãå¿ èŠããããŸãã ããããªããšã誀ã£ãŠå€ãããŒã¿ãããŒã¿ããŒã¹ã«æžã蟌ãå¯èœæ§ããããŸãã
äžè¬ã«ãããŒã¿ããŒã¹ã®æäœã¯ãã³ãŒããèšè¿°ãããªã¢ã¯ãã£ãã¹ã¿ã€ã«ã«éåžžã«äŸ¿å©ã«çµ±åãããŠããŸãã éåæãã©ã³ã¶ã¯ã·ã§ã³ãã³ãã¬ãŒãïŒåã ã®ãªããžã§ã¯ãã®èªã¿åã/æžã蟌ã¿/å€æŽïŒã¯ãããšãã°ReactiveCocoaã·ã°ãã«ã§ã©ããããã®ãéåžžã«ç°¡åã§ããããã¯ãŒã¯èŠæ±ãéä¿¡ããã³åŠçãã1ã€ã®ãã§ãŒã³ã§ããŒã¿ããŒã¹ãšäœæ¥ãçµ±åããŸãã
ã¢ããªã±ãŒã·ã§ã³ã¢ãŒããã¯ãã£
ã¢ãŒããã¯ãã£ã«ã€ããŠã¯ããŸã觊ããŸãããããã®ãžã£ã³ã«ã®æ³åã«ã€ããŠã¯è§ŠããŸããã MVVMã«é¢ããå€ãã®ã¬ããŒããšèšäºãæ¢ã«ãããŸãïŒããšãã°ãObjective-C b RACã®ããŒãžã§ã³ã®å€å žçãªãã¥ãŒããªã¢ã«ïŒ ããŒã1 ã ããŒã2 ããŸãã¯Swiftã®ãã®ãã¿ãŒã³ã®å®è£ ã«é¢ããèšäº ïŒã
ViewModelsã¬ã€ã€ãŒã®äžã«ã¯ãããžãã¹ããžãã¯ããããã³ã«ããžãã¯ãããã³ãã£ãã·ã³ã°ãå®è£ ããïŒããã³å¯èœã§ããã°ã«ãã»ã«åããïŒãµãŒãã¹ã®ã»ããããããŸãã ã¢ããªã±ãŒã·ã§ã³å ã®ããã²ãŒã·ã§ã³ã¯ãããããã«ãŒã¿ãŒãã€ãŸãç»é¢ãéãããã«å¿ èŠãªã³ãŒããã«ãã»ã«åãããªããžã§ã¯ãã䜿çšããŠå®è¡ãããŸãã å®éãã«ãŒã¿ãŒã¯éåžžã«å€ªã£ããŽãããªããžã§ã¯ãã«ãªãåŸåããããããããã»ã¹ã«ã¯è€æ°ã®ã«ãŒã¿ãŒããããŸããã ãããã£ãŠãå¯èœãªéãããããå解ããããšããŸãã ããšãã°ãåå¥ã®ã«ãŒã¿ãŒããŠãŒã¶ãŒç»é²/èªèšŒããã»ã¹å šäœãæ åœããŸãã
以åã®ãããžã§ã¯ãã®çµéšãããäŸåæ§æ³šå ¥ã¯ã¢ããªã±ãŒã·ã§ã³ã®æ§é ãå€§å¹ ã«ç°¡çŽ åããã¢ãŒããã¯ãã£ã®å€æŽãå€§å¹ ã«ä¿é²ããããšãããã£ãŠããŸãã æåã¯DIã«Typhoonãã¬ãŒã ã¯ãŒã¯ã䜿çšããŸããããã¢ããªã±ãŒã·ã§ã³ã®èµ·åæéã®æé©åäžã«ãäŸåé¢ä¿ã®è§£æ±ºã«ã¯ã¢ããªã±ãŒã·ã§ã³ã®èµ·åã«èš±å®¹ã§ããªãã»ã©é·ãæéããããããšãããããŸããïŒåŒ±ãããã€ã¹ã§ã¯æ°ç§åäœïŒã ãããã£ãŠãããããã£ããŒã¹ã®æ³šå ¥ãä»ããŠæåDIã«åãæ¿ããŸããã ãã以äžã®ã³ãŒãããããšã¯èšããŸãããã¢ããªã±ãŒã·ã§ã³ã®ãµãŒãã¹ã®ã¬ãã«ã¯éåžž1ã€ã®ã¯ã©ã¹ã§æ§æããããµãŒãã¹ã®æ§æå šäœãèªã¿ãããã§ãã ãã¡ãããå ±ææ¡åŒµæ©èœãšimessageæ¡åŒµæ©èœã®å ŽåããµãŒãã¹ã¯åå¥ã«èšå®ãããŸãããã®å Žåãå¿ èŠãªãµãŒãã¹ã¯ã¯ããã«å°ãªãããã§ãã
ãããã£ãŠãã³ãŒãã®äžè²«æ§ã¯åœåããã»ã©å€§ãããªããéçºã®éå§ããããªãé·ãæéãçµéããåŸã§ããã¡ãã»ã³ãžã£ãŒã®å éšããžãã¯ã®ã»ãšãã©ãå®è£ ããå¥ã®ã©ã€ãã©ãªïŒããæ£ç¢ºã«ã¯ãã©ã€ãã©ãªã®ã»ããïŒã«äžéšã®ãµãŒãã¹ãšãµãŒãã¹ã³ãŒããç°¡åã«è»¢éã§ããŸããããããã³ã«ã®åŠçãšãã£ãã·ã¥ãå«ã¿ãä»ã®ã¢ããªã±ãŒã·ã§ã³ã«çµã¿èŸŒãããšãã§ããŸãã
ãããã«
ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãŸãã¯ãªãã©ã€ã³ã§ã®äœæ¥-ç§ãã¡ã«ãšã£ãŠãããã¯ãã¬ã³ãã«ãªããããšããé¡æã§ã¯ãªããç¹å®ã®ãŠãŒã¶ãŒã«ã³ãã¥ãã±ãŒã·ã§ã³ããšãããã®äŸ¿å©ãªæ©äŒãæäŸããå®éã®æ¹æ³ã§ãã é«äŸ¡ãªã¢ãã€ã«ãã©ãã£ãã¯ãŸãã¯åã«æªãã€ã³ã¿ãŒããããæã£ãŠãã人ã ãããŠãããã¯ããŸãããããã®ããªãæ·±å»ãªåæ©ã§ãã çµæãšããŠãè©äŸ¡ããã®ã¯ãŠãŒã¶ãŒæ¬¡ç¬¬ã§ããã¡ãã»ã³ãžã£ãŒãã€ã³ã¹ããŒã«ããã³ã¡ã³ãã§ãã£ãŒãããã¯ãå ±æããããšããå§ãããŸãã ç§ã¯è³ªåã«çããŠããããã§ãã