Which it is the place for NSFetchedResultsController in VIPER architecture?

◇◆丶佛笑我妖孽 提交于 2020-01-03 09:11:46

问题


In VIPER, unlike the MVC, the role and place not so clearly defined for NSFetchedResultsController.

Is it right to place it on the interactor?


回答1:


According to this article interactor should not know how to persist the entities.

VIPER and the architecture that uses NSFetchResultController are different approaches. There is no right place for NSFetchResultController in VIPER.

VIPER is good for big application as it provides architecture layers that are isolated well.

NSFetchResultController is good for smaller application as it helps to develop faster.




回答2:


NSFetchedResultsController is a Core Data specific way for observing database changes. It's a popular pattern to use and can be found in most mobile database systems.

It's possible to use this kind of observation underneath a database abstraction layer, so if we take a full VIPER architecture of a mobile application it can be implemented underneath the Interactor. According to the accepted answer it shouldn't be put into the Interactor, because the Interactor shouldn't know about the type of local database it's using. Though I can't come up with anything against using it at a database level.



来源:https://stackoverflow.com/questions/38453155/which-it-is-the-place-for-nsfetchedresultscontroller-in-viper-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!