P
P
Petrushka2016-09-20 13:45:29
Objective-C
Petrushka, 2016-09-20 13:45:29

How to write VIPER correctly?

Hello everyone, tell me how to do it better
I write on VIPER
Presenter says Iteratory give me a list of news
How convenient it is for me to do:
1) Iterator receives an array of models like NewServerModel via ServerManager (fields: picture, text)
2) Iterator saves/updates new data via CoreDataManager
3 ) Iterator through the NewsMapper class throws NewServerModel into NewsMapper and gets NewsUIModel as output (in which I think what should be the height of the cells and other logic, fields like: picture, text, height, width and other UI model logic)
4) If there is no Internet, Iterator takes data from the database and does the same as point 3, only throws NewsCoreDataModel
5) And finally, Iterator gives an array of UIModels to Presenter
As a result, the Presenter received data in type 1 (NewsUIModel) and he doesn’t care about the Iteratora logic.
But as far as I know, the preparation of the data display lies on Presentare, so he must do step 3! But then it turns out that Iterator can throw data of both the CoreDataModel and ServerModel types, and here it turns out to be a mess
. I thought I could save the ServerModel to the database and then take data from the database, but it’s stupid that I saved the data, and now I got
it. Advise how best to do this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2016-09-22
@petruska

In my opinion, you confused what should be done. You get an Iterator and Models and overtakes them in UIModels.
The iterator should give models. And he must do the reduction to one common one.
The presenter must process events that occurred on Vyu and transmit data to Vyu ... and communicate with the Router.
And only Vyuha is engaged in displaying data - translating models into UIModels.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question