Upgrade to Pro — share decks privately, control downloads, hide ads and more …

VIPER - или то, о чем все говорят, но никто не ...

VIPER - или то, о чем все говорят, но никто не рассказывает

VIPER - это подход к архитектуре слоя presentation iOS-приложений (то есть всеми любимых Massive View Controller'ов), основанный на разбитии логики на несколько основных составляющих с едиными ответственностями: view, presenter, interactor и router.

Выступление охватывает следующие темы:
- Структура VIPER-модуля
- Связь модулей
- Возможности, открываемые использованием VIPER

Egor Tolstoy

November 18, 2015
Tweet

More Decks by Egor Tolstoy

Other Decks in Technology

Transcript

  1. - (void)viewDidLoad { [super viewDidLoad]; } [self setupBarWithTitle:@"#mbltdev"]; - (void)setupBarWithTitle:(NSString

    *)title { self.navigationItem.title = title; } View Presenter Interactor Router
  2. View Presenter Interactor Router Lifecycle Navbar Setup Handles events BOOL

    valid = [self.inputValidator validatePhoneNumber:phoneNumber]; if (valid) { } else { } [self processToNextScreen]; [self showErrorAlertView];
  3. View Presenter Interactor Router Lifecycle Navbar Setup Handles events if

    (valid) { } else { } [self processToNextScreen]; [self showErrorAlertView]; Data validation
  4. View Presenter Interactor Router Lifecycle Navbar Setup Handles events if

    (valid) { } else { } [self showErrorAlertView]; Data validation [self processToNextScreen]; Module Routing
  5. View Presenter Interactor Router Lifecycle Navbar Setup Handles events if

    (valid) { } else { } Data validation Module Routing [self showErrorAlertView]; Shows data
  6. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else [rootSavingContext performBlock:^{ Message *message = [Message MR_findFirst]; }];
  7. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage
  8. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage NSURLSessionDataTask *dataTask = [self.session dataTaskWithRequest:request]; [dataTask resume];
  9. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking
  10. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { segue.destinationViewController.inputData = @"inputData"; }
  11. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking Segues
  12. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = [tableView dequeueReusableCell]; [cell setupWithObject:cellObject]; } Segues
  13. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking Segues Table DataSource
  14. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking - (void)panGestureRecognizerDidChangeState:(id)sender { CGPoint panPoint = [sender translationInView:self.view]; self.view.frame = CGRectMake(panPoint.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height); } Segues Table DataSource
  15. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking Simple gestures Segues Table DataSource
  16. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking Simple gestures if (panPoint.x > 100.0f) { } [self showSideMenu]; Segues Table DataSource
  17. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking Simple gestures if (panPoint.x > 100.0f) { } [self showSideMenu]; Side Menu Segues Table DataSource
  18. View Presenter Interactor Router Lifecycle Navbar Setup Handles events Data

    validation Module Routing Shows data if-else Data storage Networking Segues Table DataSource Simple gestures Side Menu if (panPoint.x > 100.0f) { } Complex gestures
  19. Open Source •Рамблер.Конференции - приложение •Generamba - генератор •VIPER McFlurry

    - библиотека •The Book of VIPER - сборник статей https://github.com/rambler-ios