ã¨ãã«MacãiPhoneã®ããã°ã©ã éçºã§æåã«ããããªããªãã®ããã®ããããAppleãããã¯ç解ãã¦ãã¦ãYour First Mac Applicationã®ä¸ã®Understanding Fundamental Design Patternsã¨ããç« ã«ã¾ã¨ãã¦ããã¾ãã
åãã¾ã æ £ãã¦ãªãã®ã§ããã®æç« ãèªãã§ã®ç¾æç¹ã§ã®ç解ãä¸ã«ã¾ã¨ãã¦ããã¾ããã
Model-View-Controller
ãã®æãåãBASICã§ããã°ã©ã ãæ¸ãã¦ããã¨ãã«ã¯ãã¼ã¿ãã³ã¼ããä¸ç·ããã§ãããã«ã¹ãã²ããã£ã»ã³ã¼ãã«ãªã£ããã®ã§ãããJavaã®ãããªãªãã¸ã§ã¯ãæåè¨èªã使ãããã«ãªã£ã¦ããã¼ã¿æ§é é¨åã¨ãã®è¡¨ç¤ºé¨åã¨ã¯åãåããæ¹ãããã¨å¦ã³ã¾ããã
ãã¨ãã°RPGãä½ã£ã¦ããã¨ãã«ãä½åç¹ã¨ãæè¡ç¹ã®ãããªä¸»äººå ¬ã®åºç¤ãã¼ã¿ãä¿ç®¡ã»ç®¡çããé¨åã¨ãããããç»é¢ã«æ£ã°ã©ããªã©ã§è¡¨ç¤ºããé¨åã¯å¥ã®ããã°ã©ã ã«åãã¦ãããã»ããè¯ãããã¨ãããã¨ã§ãã
ãããããä¸æ©é²ãããã¼ã¿æ§é ï¼Modelï¼ã表示ï¼Viewï¼ããããäºè éã®ããã¨ãï¼Controllerï¼ã®3ã¤ã«åããã®ãMVCã§ããControllerã¯ããã¼ã¿ãæ´æ°ããããã表示ãå¤åãããã¨ããç»é¢ä¸ã®ãã¿ã³ãã¯ãªãã¯ããããããã¼ã¿ãæ¸ãæãããã¨ãããã¼ã¿é¨åã¨è¡¨ç¤ºé¨åï¼å ¥åºåï¼ã®éã§ãã¡ããã¾ãã¨åãã¾ãã
Delegate
代ç人ã¨ãå§è²ã¨ã訳ããã¦ãã¾ãããåã®ã¤ã¡ã¼ã¸ã§ã¯å¾è¦äººã¨ãä¿è·è ã§ãããªãã¸ã§ã¯ãã¨ç´æ¥ããã¨ãããã®ã§ã¯ãªããéã«å¾è¦äººãæãã§ã³ãã¥ãã±ã¼ã·ã§ã³ãã¨ããã¨ã§ããäºãã«é¢åãªæããããªãã¦æ¸ãï¼ãããã¯ãªãã¸ã§ã¯ããä¿è·ã§ããï¼ã¤ã¡ã¼ã¸ã
ãã¨ãã°ã¹ãã¼ã«ã¼é³éãã¤ããã©ããªãã¸ã§ã¯ãã®å¤ã100ã«å¤æ´ãããã¨ãã¾ããDelegateã«ãé³éã100ã«ããããã ãã©ãã¨ã¡ãã»ã¼ã¸ãéãã¨ãDelegateããããããã³ç«¯åã«ãªã«ãæ¥ç¶ããã¦ããããä»ã¯é³é0ã®ã¾ã¾ã«ãã¦ããã¾ããã¨çãã¦ãããããã¾ããDelegateãããªãç¶æ³ã ã¨ãããããã³ç«¯åã®ãã§ãã¯ããããã¨ããä½è¨ãªæéãèªåã§ãããªãã¨ããã¾ããã
Target-Action
MVCã®Viewé¨åã¯ãã¿ã³ãã¹ã©ã¤ãã¼ã¨ãã£ãã¦ã¼ã¶ã¼ããã®å ¥åãåãä»ãããªãã¸ã§ã¯ãã§ãè¯ããããªã®ã§ããããããæ¼ãããã¨ãããããªã¡ãã»ã¼ã¸ï¼actionï¼ããã£ãå ´åããããé©åã«å¦çã§ããå¥ãªãã¸ã§ã¯ãï¼targetï¼ã«ãããã¦ããå¿ è¦ãããã¾ãããããTarget-Actionã¨ããä»çµã¿ã§ãã
ãOKãã ã£ãããCancelãã ã£ããããã¿ã³ãã¨ã«æ©è½ãéãã¾ããããããããã®ãã¿ã³ããã®actionã¡ãã»ã¼ã¸ãé©åãªtargetã«éãããããã«ãã¦ãããªãã¨ããã¾ããã