ããªãã¯ç§ãèªæ ¢ããŠãããšæããããããŸãããããããã ãã®èæ¯ã¯ãããæ·±ãäžååé³ã«å¿ èŠã§ãã 建ç¯ã«ã€ããŠè©±ãããã§ãã ã¯ããç§ã¯ç¥ã£ãŠããŸããã å¯èœãªéã ããšã 圌ãèªåèªèº«ã«èš±å¯ãããã® ãã ãããããã¿ãŒã³ã«ã€ããŠã§ã¯ãªãããã¿ãŒã³ã®äœ¿çšæ¹æ³ã«ã€ããŠã話ããŸãã ãããã¯ç§ãæ¢ããŠããŠæããèšäºã§ãã Swiftã®æ°ããããŒãžã§ã³ããªãªãŒã¹ããããšãã®ãšã©ãŒããããã·ã³ã°ã«ãã³ãšãã¡ã¯ããªãŒã®äŸãå€ããããŸãããŸãã ã©ã€ãã©ãªãŒãäŸãšããŠäœ¿çšããäžè¬çãªã¢ãããŒãã«ã€ããŠèª¬æããŸãã
ãã€ãã³ã°ã®åã«æ瀺ãèªãã§ãã ããã
ç§ã¯ãéæ¹ããªãã¬ãã«ã®iOã®éçºè ã ãšã¯èšããŸããã®ã§ãèšãããããšãã¹ãŠã«æ¹å€çã«ãªããããé¡ãããŸãã ç§ãããçµéšè±å¯ãªäººããããšç¢ºä¿¡ããŠããŸãã ãããã倱ãããéã«ãšã£ãŠãæšæ¥é åããœãŒãããããã«ã¯ã客芳çã§ããããšã¯è¯ãããšã§ãã ãã£ãŠã¿ãŸãã
ãããããããïŒ æ²¡å ¥ïŒ
ãã®ãããžã§ã¯ãã¯ãæš©éã䜿çšããŠäœæ¥ãç°¡çŽ åããŸãã ããã«ãåãéç¥ãåä¿¡ããããã«å€æãå¢å ããŸãã çŸãããã€ã¢ãã°ããã¯ã¹ãå«ããªäººã¯èª°ã§ããïŒïŒ
ãããžã§ã¯ãã®åºæ¬èŠä»¶ïŒ
- ç°¡åãªå®è£
- ç°¡åãªäœ¿çš
- 䟿å©ãªã«ã¹ã¿ãã€ãºãšæ¡åŒµïŒçªç¶æ°ããã¢ã¯ã»ã¹èš±å¯ãŸãã¯ããžã¥ã¢ã«ãè¿œå ããå ŽåïŒ
æ®ãã¯ããŸãããããšããŸããïŒããšãã°ãããžãã¹ããžãã¯ãå€æŽããæ©èœã¯åªå äºé ã§ã¯ãããŸããã§ããããèæ ®ãããŸããïŒ
ããã§ã¯è©±ããŸãããã ããã¯äžè¬çã«äŸ¿å©ãªããšã§ãã ãããžã§ã¯ããã·ã³ãã«ã«ããããã«ã¯ãã·ã³ãã«ãªã€ã³ã¿ãŒãã§ãŒã¹ãæã¡ãããã°ã©ããŒã«å éšã®å®è£ ãããŒãããªãããã«ããå¿ èŠããããŸãã ãã®ç¹ã§ãç§ã¯Appodealããã®ã¢ãããŒãã«è§ŠçºãããŸããã äžè¬ã«ããšã³ããªãã€ã³ãã¯1ã€å¿ èŠã§ãã ã€ãŸã ãªããžã§ã¯ãã«2ã€ã®æš©éãèšå®ããèŠæ±ããŸããã ç°¡åã«èãããã¯ãã§ãïŒ
ããã«å·Šã®æªéïŒ è©ã«ããããïŒãã·ã³ã°ã«ãã³...ãã ãããŠãæåã®æ¥ã¯çŽ æŽããããœãªã¥ãŒã·ã§ã³ã«æããã®ã§ãAppDelegateã§æ§æããã³ã³ãããŒã©ãŒãå¿ èŠãªå Žæã«è¡šç€ºããŸããã
ããããããã«åé¡ããããŸããïŒ
- ãã€ã¢ãã°ããã¯ã¹ã念é ã«çœ®ãããšã¯éåžžã«ãŸãã§ã
- ãã¹ãŠã®èš±å¯ãååŸããåŸãããªãã¯ééããªããããããªãã®èšæ¶ã«ä¿æããå¿ èŠã¯ãããŸãã
- ç°ãªãç»é¢ã§åãæš©éãèŠæ±ããå¿ èŠã¯ã»ãšãã©ãããŸãã
äžè¬ã«ããã¿ãŒã³ã«ã¯ãã©ã¹ããããã€ãã¹ãå€ããããŸããã ããã§ã¯ããããžã§ã¯ãã䜿çšããããã®ãªãã·ã§ã³ã«åºã¥ããŠãããšããäºå®ã«æ³šæãåèµ·ããããšæããŸãã Singletonã®äœ¿çšã¯æ£åœã§ãããšç¢ºä¿¡ããŠããŸãããä»ã®ç¶æ³ã§ãããã§ãã
ã¿ãŒãã³ã°ãã€ã³ãã§ãç§ã®èŠè§£ã¯ãæ¢ç¥ã®Androidéçºè Aleksey Skutarenkoã«ãã£ãŠç¢ºèªãããŸããã圌ã¯ãã®ãã¿ãŒã³ããçãããããšåŒã³ãŸããã ãã®ãã¿ãŒã³ãå«ããªã®ãããããšãç§ã®ããŒãºã«æé©ã«é©çšã§ããªãã®ãã¯äžæã§ãã ãããã20æã®å€çŽãæšãŠãŠæ°ãããã®ãæã«å ¥ãããšãã決æãäžãããŸããã å®éãããŒã«ãŒãçµäºããŸããã
ããããå察ããè¡ãããšã«ããã ãããžã§ã¯ãã®äœ¿çšæ¹æ³ãæããŠãã ããã ç§ã¯ãããæ確ã«è¡šããŠããŸãïŒ
class ViewController: UIViewController { var permissionAssistant = SPRequestPermissionAssistant.modules.dialog.interactive.create(with: [.Camera, .PhotoLibrary, .Notification]) override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) self.permissionAssistant.present(on: self) } }
ãœãªã¥ãŒã·ã§ã³ã¯èªç¶ã«çãŸããŸãããã¡ã€ã³ã¯ã©ã¹ãå¿ èŠã§ãããPermissionAssistantãšåŒã³ãŸãã ãããŠãããžãã¯ãããŒãããã¯ã«åå²ãã䟿å®äžãããããã¯ãŒããããŒãžã£ãŒãšçµã¿åãããŸãã ãããŠãããã¯è«ççã«ãç°ãªãã¿ã¹ã¯-ãããã£ãŠãç°ãªãã¯ã©ã¹ãããããæ åœããŸãã
ããã§ã¯ãæ©èœéšåã決å®ããŸãããã æããã«ããããã®1ã€ãèš±å¯ã®èŠæ±ãšãããã«é¢ããæ å ±ã®ååŸãæ åœããŸãã PermissionsManagerãšåŒã³ãŸãã èŠèŠçãªéšåãå«ãŸããŠãããããPresenterManagerãè¿œå ããŸãïŒViperã®åœåèŠåãææããŸããçºèŠè ã§ååãªå ŽåããããŸãïŒã
ãã¬ãŒã³ã¿ãŒã¯ãã³ã³ãããŒã©ãŒã®ãã¬ãŒã³ããŒã·ã§ã³ããã®æ§æãäžè¬çã«UIã®è²¬ä»»ãè² ããŸãïŒãã¡ãããããããå ŽåïŒã ãšããã§ãå°æ¥ã®æè»æ§ãé«ããããã«ããã¹ãŠã®éšåããããã³ã«ã«ãã£ãŠé ãããŠãããšããäºå®ã«æ³šç®ããŸãã
æè»æ§ïŒïŒ
ã¯ã ãã¶ãæé«ã®èšèã§ã¯ãããŸããããæ¬è³ªãåæ ããŠããŸãã æœæ°ŽèŠãä¿®çããŠãããšæ³åããŠãã ãããããžããŠã³ãã¯29ã€ã³ãã®16ã·ãŒãã¹ã¬ããïŒçºæãããã°ããïŒã§ãã æ¯åæ°ããæœæ°ŽèŠãäœæããå¿ èŠã¯ãããŸãããæ¢ç¥ã®èŠä»¶ãæã€ããžãäœæããŠåºå®ããã°ååã§ãã äœããçããŸãã
ç§ã¯all話ã®é人ã§ã¯ãããŸãããããšãã°ã³ãŒããèŠãŠã¿ãŸãããã PermissionsManagerã調ã¹ãŠããããã³ã«ãšå®è£ ã«ãã£ãŠé ãããŠããŸãã æåã«ããããŒãžã£ãŒã®æ©èœãå®çŸ©ããŸãã 2ã€ã®æ¹æ³ã§ååã§ãã
- èš±å¯ã®ãªã¯ãšã¹ã
- èš±å¯ãæ¿èªãããŠããŸã
æ©èœã奜ã¿ã«åãããŠæ¡åŒµã§ããŸãããããã§ååã§ãã ãããŠããããã³ã«ïŒ
protocol PermissionManagerInterface { func requestPermission(_ type: PermissionType) func isAllowedPermission(_ type: PermissionType) }
ç§ãã¡ã®å Žåããããã¯ããŒãã®ãããã©ã®èŠä»¶ã§ãã
次ã«ããããã³ã«ãå®è£ ããŸãã å®éã®ãªããžã§ã¯ãïŒããžïŒãååŸããŸãã åºå®ããŸãã ããããã¡ã€ã³ã¯ã©ã¹ã®ã¢ã·ã¹ã¿ã³ãïŒæœæ°ŽèŠïŒã¯ãã©ã®ç¹å®ã®å®è£ ïŒã©ã®éå±ãããäœæ¥æ³šå ¥ãããã©ã®ãããã®äœæ¥ã³ã¹ããããããïŒãç¥ããŸããã ã¡ã€ã³ã¯ã©ã¹ã¯ã2ã€ã®é¢æ°ãããªãããšãç¥ã£ãŠããŸãã å®è£ ãå€æŽãããå Žå-ãã ããïŒããžã¥ã¢ã«ããŒããšDataSourceã®ã«ã¹ã¿ãã€ãºã«ç¹ã«åœ¹ç«ã¡ãŸãã ä»ãã圌ã«ã€ããŠè©±ããŸãã
æããã«ãèŠèŠçãªéšåã¯åãªããã¬ãŒã³ã¿ãŒãããã¯ããã«è€éã§ãã è¯ãããšã«ã¯ãã¢ãžã¥ãŒã«ã«åå²ããå¿ èŠããããŸãã å®éã«ã¯ãã³ã³ãããŒã©ãŒãšããŒã¿ãœãŒã¹ã®2ã€ã®éšåã«åããŸãã
ãã¬ãŒã³ã¿ãŒã¯ã³ã³ãããŒã©ãŒãä¿æãããžã§ã¹ãã£ãŒãç»é¢ãããã³ã³ã³ãããŒã©ãŒãè¡ããã®ä»ã®ããšãåŠçããŸãã ãã¡ãããåé¡ã¯ã³ã³ãããŒã©ãŒãã¢ã¯ã·ã§ã³ãã©ã®ããã«å ±åãããã§ãã ç¹ã«å¥œå¥å¿onesçãªäººã¯ããARCã¯1æéã§ãã¹ãŠãå°çã«ç Žå£ããããšã¯ãªãã ãããïŒããšããçåãæ±ãã§ãããã
æåã®è³ªå-ããªã²ãŒãã§ãã¹ãŠãæ確ãªå Žåã2çªç®ã¯1é±éç§ã®ä»äºãæ¢ããåé¡ã§ãã ããããç解ããããã«ããªããžã§ã¯ãéã®ãªã³ã¯ã§ã¹ããŒã ãè£è¶³ããŸããïŒåŒ·ããªã³ã¯ãšåŒ±ããªã³ã¯ã«ã€ããŠèª°ããç¥ã£ãŠããããšãæã¿ãŸãã質åã¯ãããŸããïŒã
åé¡ã¯æããã§ãïŒé¡ã£ãŠããŸãïŒ-ã³ã³ãããŒã©ãŒã¯Assistantãªããžã§ã¯ãïŒãã¡ããããã¬ãŒã³ã¿ãŒã§ãããã¢ã·ã¹ã¿ã³ããä¿æããŠããã®ã§ããªã³ã¯ãããããããŸãïŒã®ã¿ãä¿æããŸãã åé¡ããŸã æ確ã§ãªãå Žåãç§ã¯èª¬æããŸãïŒ
Assistantãªããžã§ã¯ããã¹ã³ãŒãå€ã«åºãŠãããã«å¿ããŠARCã®å€åŽã«æãããããšæ³åããŠãã ããã ã³ã³ãããŒã©ãæ瀺ãããªãã£ãå Žåããªããžã§ã¯ãå šäœãæ»ã«ãŸãã ããã¯æ£ããåäœã§ãã ããããã³ã³ãããŒã©ãŒãæ瀺ãããå Žå...
ãã®åŸãã¹ã¿ãã¯ã®ééã枬å®ããŸãããããã£ãŠããªããžã§ã¯ãã®å€éšã«ãªã³ã¯ããããŸãã ããããã¢ã·ã¹ã¿ã³ããèŠç·ãé¢ãããšãæ»ãã§ããŸããŸãã ç°¡åãªäŸã§ãã¢ã³ã¹ãã¬ãŒã·ã§ã³ã§ããŸãã
if true { let permissionAssistant = SPRequestPermissionAssistant.modules.dialog.interactive.create(with: [.Camera, .PhotoLibrary, .Notification]) permissionAssistant.present(on: self) }
ã³ã³ãããŒã©ãŒã¯çããŠãããããã¹ãŠã®ç°å¢ã¯ã©ã¹ãæ»ã¬ç¶æ³ã«ãªããŸãã ãããŠãåžäŒè ãåãããã¬ãŒã³ã¿ãŒã§ããã
æ²ãã
-ç§ã¯èããŠãããããã®ãã¿ãŒã³ãæ·±ãæãäžãããã¿ãŒã³ã«ã€ããŠèªãã§ïŒããããç§ã¯ããã€ããèŠéããïŒãäžè¬çã«ãã®äžçããèœã¡ãŸããã æ°Žæ³³ã«æ²¡é ã
åé¡ã«é¢ããäŒè©±ãäœåãã£ããã圌ã¯
ã³ã³ãããŒã©ãŒãã¡ã€ã³ãªããžã§ã¯ããšããŠäœæããŠãã ããïŒ ã³ã³ãããŒã©ãŒå ã§ããžãã¯ãäœæããã«ã¯-ãŸãããããã
決å®ã¯ããèªäœã§ãè¶ã飲ã¿ãªããè¡ãããå°ãæŽå¯åããããŸããïŒ
ãã©ãããŠïŒã
ã¢ã·ã¹ã¿ã³ããã³ã³ãããŒã©ãŒã³ã³ãããŒã©ãŒãšããŠåæåããã ãã§ã-以äžã§ãïŒ èŠªãçããŠããéãã¢ã·ã¹ã¿ã³ããçããŠããŸãã ãŸãããã¹ãŠã®å¯Ÿè©±ã³ã³ãããŒã©ãŒã¯ã¢ãŒãã«ã§ããããããœãªã¥ãŒã·ã§ã³ã¯å®å šã«æ©èœããŸããã ãã®æ±ºå®ã¯ç§ã«ãšã£ãŠæé©ã§ããããã«èŠããŸããããå éšã®ããã³ããªãŒã¯æ²ãããã®ã§ããã ãããç¶ããŸãããã 粟ç¥ãåäžããåã³ã¹ããŒããäžãããŸããïŒ
ããã§ãUIãšPermissionManagerãåé¢ãããšããã§ãããã ããã§ã¯ãã¹ãŠãç°¡åã§ãã次ã®ãããªPermissionInterfaceãããã³ã«ãäœæããŸãã
protocol PermissionInterface { func isAuthorized() -> Bool func request(withComlectionHandler complectionHandler: @escaping ()->()?) }
ãããŠãæ°ããpermishinïŒãã±ãŒã·ã§ã³ãéç¥ãã«ã¡ã©ãªã©ïŒããšã«å®è£ ããŸãã ãããŠãPermissionManagerã§å¿ èŠãªPermissionã¯ã©ã¹ãäœæããå¿ èŠãªæ©èœãåŒãåºããŸãã
ã¹ããŒã ãæŽæ°ããŸãã
ä»ãå šäœåãèŠãããšãã§ããŸãã ã芧ã®ãšãããã¬ã³ã¬ã亀æã§ããŸãã å人çã«ã¯å€§äžå€«ã ãšæãã ãããã¯ãäœãã»ã©ãæžãæããå¿ èŠãå°ãªããªããŸãã æ°ããã³ã³ãããŒã©ãŒãå®è£ ããã«ã¯ããã®ã€ã³ã¿ãŒãã§ãŒã¹ãå®è£ ããçŸåšã®ã·ã¹ãã ã«å®è£ ããå¿ èŠããããŸãïŒããžãã¹ã¯ã©ã®ããã«ïŒã ããã¹ããšè²ãå€æŽãããã§ããïŒ DataSourceãããã³ã«ãå®è£ ããŸãã ç¹ã«ãPresenterManagerãè€æ°æã€ãšããã¢ã€ãã¢ãæ°ã«å ¥ã£ãŠããŸãã ããã§ããã€ã¢ãã°ããã¯ã¹ãšå¥ã®ç»é¢ã«-äžéšã«ãããã¢ãããããŒãå¿ èŠã§ãïŒéçºäžïŒ
ãããã¿ã€ã
æã®æ°ã¯ã³ãŒãã®å質ãšåŒ±ãçžé¢é¢ä¿ãããããšãå®å šã«ç解ããŠããŸããæããã«ããã¹ããããã«ã€ããŠã§ã¯ãªãããšãé¡ã£ãŠããŸãã
ãããžã§ã¯ãã®é²è¡äžã«ãå€ãã®ãã³ããåŸãŠãç¹å®ã®ãã¿ãŒã³/ã¢ã€ãã¢ãæ©èœããªãçç±ãïŒèªåèªèº«ã§ïŒè°è«ããã®ã«å€ãã®æéãè²»ãããŸããã ãããŠããã¯è¯ãããšã§ã ãç§ã¯å€ãã®ä»äºãããŸããã
ç§ã¯èªåèªèº«ã«å©èšãäžããäœè£ã®ããéçºè ãšã¯èããŠããŸããã ããããå°ã話ãããŸãããããããžã§ã¯ãã«ã€ããŠèãå§ãããšããç§ã®èŠªåã§ããGennadyïŒååãå€æŽããŸãïŒã¯ãã·ã³ã°ã«ã¹ã¯ãªãŒã³ã¢ããªã±ãŒã·ã§ã³ã«åãçµãã§ããŸããã 圌ã¯VIPERã§ãããããŸãããããªãããã䜿çšããã®ãããããŠãªãããã䜿çšããã®ããæ¬åœã«ç解ããŠããŸããã§ããã ç§ã®è°è«ã«ïŒ
-ã åé¡ãææŸããªããããªãããªãã¯è¶ åçŽãªã¢ããªã±ãŒã·ã§ã³ã§éããã¿ãŒã³ãå¿ èŠãªã®ã ã
圌ã¯é åºã§ããã æ°ã¶æãçµã¡ãç§ã¯å°ããªãããžã§ã¯ããå®çŸããã¢ããŒããæé€ãã倧ããªãã®ãè²·ãã顧客ã«ä»äºãåŒãæž¡ããæ¥ãæ¥ãŠããæ§åãèŠãŸããã Gennadyã¯ã¢ããªã±ãŒã·ã§ã³ã®äœæãç¶ããŠããŸã...
ãã¿ãŒã³ã¯ãã¹ãŠã®ç æ°ã®äžžè¬ã§ã¯ãããŸããã ããæèã®ææšãšããŠããŸãã¯ã æç¥ããããã ã ããã«äœ¿çšããªãã§ãã ããã MVCãããéãšãããã¹ã¯MVCããäœæããŠããæã¯ä¹ŸããŸããã ãããå¿ èŠã§ããããšã«æ°ä»ãããããã¿ãŒã³ã䜿çšããŠãã ããã ãããã䜿çšããŠäœæ¥ã容æã«ããŸãã ã ãã®ãã¿ãŒã³ã¯ã¯ãŒã«ãªãããžã§ã¯ãã§äœ¿çšãããŸãããšããè°è«ã¯ ãç®æšãšã¯ãŸã£ããç¡é¢ä¿ã§ããããã®ã¢ãããŒããããªãã®äººçãåçŽåããå¯èœæ§ã¯äœãã§ãããã
ç§ã¯ããã¿ãŒã³ãæŸæ£ããã³ã³ãããŒã©ãŒã«ãã¹ãŠãæžããäžè¬çã«ã¯VIPERããç£æ°éã§æã€ããšãå§ããŸããã 䜿çšããŸãããæå³çã§ãïŒ ã¢ãŒããã¯ãã£ãšå®éšã«ç¹å®ã®èŠä»¶ãèšå®ããŸã-ã¿ã¹ã¯ãããè¯ã解決ãããã®ãèŠã€ããŸãã VIPERã¯å®ç§ã§ãããã ãã¬ãŒã³ã¿ãŒãããªãã«ãšã£ãŠäžå¿ èŠã«æãããªããæšãŠãŠãã ããã éå€å žçã§ã¯ãããŸãããæè¯ã®çµæãããããã®ã¯ãã¢ãŒããã¯ãã£ã«é¢ããçµéšçãªäœæ¥ã§ãã
ç§ã®ãã¿ãŒã³ãäœãšåŒã°ããŠããã®ãããããŸããïŒã³ã³ããŒãïŒïŒ-ããããç§ã¯åœŒã圌ã«å²ãåœãŠãããã¿ã¹ã¯ãã©ã®ããã«è§£æ±ºãããã«æºè¶³ããŸããã ãã®ãããªçµæã¯ããã¿ãŒã³ã®äœ¿çšãããããã¯ãã§ãã
ã å°é家ã§ããçµµã³ã³ãã䜿çšããŸã ãæªç¥ã®èè ã
ãã¹ãŠã®æåãããã«ããšæ£çµ±ã®CTRïŒ
1幎ã®UPDïŒ
çŸåšããã®ãããžã§ã¯ã㯠2Kå以äžã®æãåéããŠãããæŽæ°ããããšã決å®ãããŸããã
æ°ãããã¶ã€ã³ãèŠã€ããããšã«é¢ãããããªãšããããžã§ã¯ãã§ã©ã€ãã©ãªã䜿çšããæ¹æ³ã«é¢ããå°ããªãã¥ãŒããªã¢ã«ãèŠãããšããå§ãããŸãã