MVVM Playground,一个照片展示应用程序
MVVM Playground,一个照片展示应用程序。
这是具有依赖注入操场的 MVVM 的示例代码。
.
├── Module
│ ├── PhotoDetail
│ │ └── PhotoDetailViewController.swift
│ ├── PhotoListWithMVC
│ │ ├── PhotoListTableViewCellWithMVC.swift
│ │ └── PhotoListViewControllerWithMVC.swift
│ └── PhotoListWithMVVM
│ ├── PhotoListTableViewCell.swift
│ ├── PhotoListViewController.swift
│ └── ViewModel
│ ├── PhotoListCellViewModel.swift
│ ├── PhotoListViewModel.swift
│ └── State.swift
├── Service
│ ├── APIService.swift
│ └── content.json
├── Model
│ └── photo.swift
默认情况下,该应用程序将运行PhotoListWithMVVM代码,如果要运行PhotoListWithMVC,则应将以下文件添加到MVVMPlayground Target(通过选中两个文件的目标成员资格部分中的框)。
- PhotoListTableViewCellWithMVC.swift
- PhotoListViewControllerWithMVC.swift
并将 Main.storyboard 中照片列表视图控制器的自定义类更改为 PhotoListTableViewCellWithMVC。